Installing Office 365 ProPlus Click To Run Via Group Policy

Note: Article updated October 2018 to remove references to “Office 2016” and replace it with “Office 365 ProPlus” as the rollover to the 2019 release is seamless and does not change this products name.

Note: Article updated April 2018 Mid 2020 to support the new Channel names and XML updates and the new name for the product (Microsoft 365 Apps for enterprise).

Microsoft 365 Apps for enterprise (aka Office 365 ProPlus) Click To Run (which comes with Office 365 subscriptions) can be deployed via Group Policy, but there are a few things that you need to know and do first. These are:

  1. You cannot use the “Software Installation” features of GPO’s to deploy the installer click to run software as this is an exe file, and “Software Installation” runs MSI files.
  2. You cannot run software with elevated installation rights, as the setup.exe shells out to other processes to run the installation (the officeclick2run.exe service).
  3. You cannot just drop the latest versions of the files in an existing 2013 deployment folder and expect the clients to update automatically – you must install 2016 to upgrade it and install it for the first time. This is not the case with the “2019” release. An existing installation installed before the “2019” release in October 2018 will seamlessly move to this version at the next applicable update.

Therefore you need to deploy the software via a computer startup script. But this is not simple either as startup scripts run each time the computer starts up (obviously!) but will run regardless of whether the software is already installed. Therefore you need to run the installation by way of a startup script that first checks if Office 365 ProPlus click to run has already been installed or not.

To do this you need to following:

  1. A read only file share containing the Office 2016 click to run files. Not this folder should not be the folder that already contains the Office 2013 files if you have them on your network.
  2. A read/write file share to store log files on (the deployment script logs the start and completion of the installation in a central location)
  3. An XML file to install Office 365 ProPlus click to run customised to your environment and the fact that you are using GPO deployment
  4. A batch file to detect an existing Office 365 ProPlus click to run deployment and if not present to install Office 365 ProPlus click to run from your file share.
  5. And finally the Office Deployment Tool setup program. This software has been updated a few times over the years, so ensure you download the current version before starting.

Steps 1 and 4 are part of a standard Office 365 ProPlus click to run deployment process and so not covered in this blog post. But once you have downloaded the Office Deployment Tool and created the XML using the creator tool at you have your configuration.xml file. In step 3 you can run the deployment tool with setup.exe /download configuration.xml to download the Office binaries to the file share mentioned in step 1. If you have Office 2013 already deployed via this method (see for these steps) then make sure that this folder for the binaries is not the same folder as contains 2013 files. The Office installer for Office 2013 Click To Run creates a subfolder called Office then another subfolder called Data. Into this it places (or and other files. This cab file contains info relating to the version number of the software in this folder and if you download the current version to the same folder it will replace this file, but 2013 installed machines will still try and upgrade from this folder and fail. Therefore create another folder. This is shown in the example scripts below.

So here are the steps and details for doing all this for GPO deployment:

Creating Deployment File Shares

Create a software deployment file share that you have read/write access to and everyone else read only and create a folder called Office365ProPlus inside this to store the binaries.

Create a second file share that everyone has read/write access to (or CREATOR OWNER has write so that only the creator of the file can write it to the share and others can read or not see it at all). Create a sub folder in InstallLogs called Office365ProPlus.

In my demo these two shares and subfolders are called \\server\Software\Office365ProPlus and \\server\InstallLogs\Office365ProPlus.

Create an XML File for Office 2016 Click to Run Deployment

This XML file is as follows and is saved to \\server\Software\Office365ProPlus root folder. Call this file config.xml. You can create this XML file using the wizard at

  <Info Description="" />
  <Add SourcePath="\\server\Software\Office365ProPlus\" OfficeClientEdition="64" Channel="MonthlyEnterprise" MigrateArch="TRUE">
    <Product ID="O365ProPlusRetail">
      <Language ID="de-de" />
      <Language ID="MatchPreviousMSI" />
      <ExcludeApp ID="Groove" />
      <ExcludeApp ID="Lync" />
    <Product ID="LanguagePack">
      <Language ID="de-de" />
      <Language ID="MatchPreviousMSI" />
  <Updates Enabled="TRUE" UpdatePath="\\server\Software\Office365ProPlus\" Channel="MonthlyEnterprise" />
  <RemoveMSI />
    <Setup Name="Company" Value="DC Advisory" />
    <User Key="software\microsoft\office\16.0\common\general" Name="shownfirstrunoptin" Value="1" Type="REG_DWORD" App="office16" Id="L_DisableOptinWizard" />
    <User Key="software\microsoft\office\16.0\excel\options" Name="defaultformat" Value="51" Type="REG_DWORD" App="excel16" Id="L_SaveExcelfilesas" />
    <User Key="software\microsoft\office\16.0\powerpoint\options" Name="defaultformat" Value="27" Type="REG_DWORD" App="ppt16" Id="L_SavePowerPointfilesas" />
    <User Key="software\microsoft\office\16.0\word\options" Name="defaultformat" Value="" Type="REG_SZ" App="word16" Id="L_SaveWordfilesas" />
  <Display Level="None" AcceptEULA="TRUE" />

The important entries of “no display” and the “Extended User Licence Agreement” having been accepted are important, as GPO deployment works as a system service and so cannot display anything to the screen. Also see for the XML reference file for other settings you can contain here such as updates from the Internet (UpdatePath=””) or no updates (Updates Enabled=”FALSE”), the Channel value names and multiple languages (add more <Language ID=”xx-xx” /> nodes to the file) or to match the language to the OS (MatchOS, with Fallback language and allowing internet download if the language is not available with AllowCdnFallback), etc.

Download the Office ProPlus Click to Run Binaries

Download the Office Deployment Tool from and if you downloaded this a few months ago, download it again as it changes frequently and improves the setup process.

Install this software to get setup.exe and some example XML files. Copy setup.exe to \\server\Software\OfficeProPlus.

Run \\server\Software\Office365ProPlus\setup.exe /download \\server\Software\Office365ProPlus\config.xml to download the latest version (or the specified version if you have added Version=”″ to config.xml where is the build number you want to install). This will create the Office\Data folder in the \\server\Office365ProPlus share and download the binaries and any languages specified in the XML to that location – do not modify the folder structure as the Office Deployment Tool will expect this structure to find the files under during installation.

Create A CMD File To Script The Install

In Notepad create a cmd file and save it to <strong\\server\Office365ProPlus as well. It will eventually go in the GPO folder location, but this will be your master copy. The cmd file will look like the following and for this demo is called _InstallOffice365ProPlusGPO.cmd

REM *********************************************************************
REM Environment customization begins here. Modify variables below.
REM *********************************************************************
REM Set DeployServer to a network-accessible location containing the Office source files.
set DeployServer=\\server\Software\Office365ProPlus
REM Set ConfigFile to the configuration file to be used for deployment (required)
set ConfigFile=\\server\Software\Office365ProPlus\config.xml
REM Set LogLocation to a central directory to collect script log files (install log files are set in XML file).
set LogLocation=\\server\InstallLogs\Office365ProPlus
REM *********************************************************************
REM Deployment code begins here. Do not modify anything below this line (check quotes are quotes though).
REM *********************************************************************
IF NOT "%ProgramFiles(x86)%"=="" (goto ARP64) else (goto ARP86)
REM Operating system is X64. Check for 32 bit Office in emulated Wow6432 registry key
reg query HKLM\SOFTWARE\WOW6432NODE\Microsoft\Office\16.0\ClickToRunStore\Packages\{9AC08E99-230B-47e8-9721-4577B7F124EA}
if NOT %errorlevel%==1 (goto End)
REM Check for 32 and 64 bit versions of Office 2013 in regular registry key.(Office 64bit would also appear here on a 64bit OS)
reg query HKLM\SOFTWARE\Microsoft\Office\16.0\ClickToRunStore\Packages\{9AC08E99-230B-47e8-9721-4577B7F124EA}
if %errorlevel%==1 (goto DeployOffice) else (goto End)
REM If 1 returned, the product was not found. Run setup here.
echo %date% %time% Setup started. &amp;amp;amp;gt;&amp;amp;amp;gt; %LogLocation%\%computername%.txt
pushd "%DeployServer%"
start /wait setup.exe /configure "%ConfigFile%"
echo %date% %time% Setup ended with error code %errorlevel%. &amp;amp;amp;gt;&amp;amp;amp;gt; %LogLocation%\%computername%.txt
REM If 0 or other was returned, the product was found or another error occurred. Do nothing.

This will be run by GPO and at computer startup look for the Click To Run registry key that indicates Office has been installed. If not found for 64 or 32 bit OS’s and 64 or 32 bit installations of Office then it will deploy office.

Create A Group Policy Object

Create in your domain a GPO object over an OU that contains the computers you want to install Office 2016 click to run on. This will run on all computers in this OU, so start with a test OU containing one or a few computers or use permissions to lock the GPO object down to specific computer accounts.

In this GPO set the following:

  1. A startup script that runs _InstallOffice365ProPlusGPO.cmd. A startup script will have a folder the script is located in (click Show Files button in the GPO editor) and copy the above cmd file from the Office deployment share to this folder.
  2. Then click Add and select the file – there are no script parameters.
  3. Your GPO object will look like this.
  4. In Adminstrative Templates/System/Scripts set the Maximum wait time for Group Policy scripts to 1800 seconds. This is 30 minutes. The default is 10 minutes (600 seconds) but I have found Office installs take just over ten minutes on a LAN and longer if the fileshare is remote to the client computer. The script will be cancelled if it takes over 30 minutes, so you may need a higher value for your network.

Deploy Office 365 ProPlus Click to Run Click To Run

Run gpupdate /force on a test computer that is under the scope of your GPO object and then reboot the computer. The installation will start automatically and Office will be ready to use a few minutes after reboot. Office takes about 10 minutes to fully install on a LAN but can be used about 2 or 3 minutes after installation starts. Though in my lab with a low resourced file server it took 30 minutes to install. Do not reboot the PC in that time.

Check \\server\InstallLogs\Office365ProPlus for a file named after the computer. This will have two lines, one for the start of the deployment and one at the end (with “Setup ended with error code 0” if successful).




125 responses to “Installing Office 365 ProPlus Click To Run Via Group Policy”

  1. bosco avatar


    there is a problem with your script : it doesn’t support office update !

    1. Brian Reid avatar

      Hi, I have the script working fine. What exactly do you mean by it “doesn’t support office update”. The XML file contains the Update= value so that updates occur automatically when new versions of Office are dropped into the source directory.

      1. bosco avatar


        i’m talking about the CMD script to install O365.

        If you upgrade (to a newer version), the script will always check if the reg key exist. If it exists, it will never install the newer version…

        1. Brian Reid avatar

          Correct. The 2013 script looked for a reg key that only exists once 2013 was installed and the 2016 key looks for a key that exists when Office 2016 exists. Therefore if you do not have any version of Office or Office 2013 C2R the script should run and update the software.
          I don’t understand the comment – if you upgrade to 2016 already, why would you need the script to upgrade to 2016 again?

          1. bosco avatar


            because every 3 months, there is a new version of Office 2016 🙂

          2. Brian Reid avatar

            Ah, that’s different – that’s not an install of Office 2016 for the first time. To do the updates you customise the config XML file to include Branch= in the Add and Updates nodes (as shown above). Branch=Business will install the updates every four months from Microsoft automatically or from your file share if you have included a path to the Updates node. Branch=Current will do monthly updates and there are options for First Release as well (see for the options). Then when you want to update the clients either they download from Microsoft directly (no Update value) or from your file share (as in this example). All you do is update the version of Office in the 2016 file share by running the download again. You are in complete control of the updates and that is in the product. What this script does is control the initial installation of the product and sets how the automatic updates happen.

          3. bosco avatar

            Yes i know.

            but how to update with the last version with your script on a compuer with office 365 already installed ?

            Also, if i remove the /wait the installer is not continuing and with the /wait, it locks the computer for about 10 minutes. Do you know a way to avoid locking the computer ?

          4. Brian Reid avatar

            Then use GPO to change the Update path value so that it points to the folder that contains the “Office\Data” subfolders. The client will then update. See

  2. Anton avatar

    Thank you for this!

    It works brilliant on fresh machines but I get the following prompt on machine that run Skype for Business 2015.
    “We need to remove some older apps”
    It prompts you to click “Remove and Continue”×234.png

    Is there anything I can put in the _InstallOffice2016GPO.cmd script to run this automatically as I’m looking to roll this out to around 150 users without them having to click anything.

    1. Brian Reid avatar

      I’m guessing that you are rolling out Office 2016 Business and ProPlus already contains Skype? How did you roll out Skype for Business, can you roll out the uninstall in the same way and chain the two installers together – the one in this blog is just a cmd file, so it could be run by anything. Though at 150 users I would look into getting something to machine the machines more than GPO.

      1. Anton avatar

        Thanks for coming back to me Brian, what would you be using to roll the install out to machines? Something like SCCM?

        I customized the config.xml file to include the product ID for Skype for Business 2016.
        The script runs perfectly but just requires you to press the button to “remove and continue”
        I was just wondering if there was a way to customize the _InstallOffice2016GPO.cmd script to uninstall previous versions of office such as office 2010 and automatically hit “remove and continue” – Scripting knowledge isn’t the greatest.

        1. Brian Reid avatar

          So yes SCCM is one of many options. Intune if you want it cloud managed, and third party products exist too.

          The uninstall of an application can be scripted to – its documented in the TechNet article for the product. So if you have Skype for Business 2015 Click to Run as part of Office 2013 Click to Run (i.e. it was Lync and it was in ProPlus) then you can roll out a script to uninstall. If it was the MSI version of the installer then you need to customise your installer process that was used back then to uninstall it.

          1. Abdul avatar

            Office Scrub works well with Office msi installs. The link below is for Office 2013. Office 2010 exists as OfficeScrub10 and a quick google search.


  3. James avatar

    We’re upgrading from a mix of MSI-installed 2010 (all apps) and click-to-run 2013 (outlook only) on one PC, to click-to-run 2016. I’ve got scripts set up similar to what you’ve got above, and everything seems to work if I double-click the script. If I set it as a startup script, the installer runs and *appears* to complete successfully but doesn’t actually install anything. All the other components I’m using worked fine for a 2013 deployment.

    I made sure to set up this deployment as a fresh install source and didn’t attempt to drop it into the existing 2013 source folders, as I’m testing it all first. I’m just puzzled as to why the installer would work flawlessly if I double clicked it as an admin, but not through group policy.

    1. Brian Reid avatar

      As I have not seen your scripts I cannot say why they are not working, but I suggest adding extra logging to the script and try again. For example, write out from the script the username the script is running as, domain membership etc. Check the fileshare has permissions for this account to access it. Record things like error status and other messages. Also look in the C2R installer logs in c:\windows\temp – they will be listed after the PC name. Look for errors here as well.

      The only obvious difference that can be seen from the info provided is the GPO scripts run as Local System ( and when you double-click the script it is running as your user/admin.

  4. Jordan Cobb avatar
    Jordan Cobb

    Where exactly do we get the .cmd file?

  5. Stephen Bell avatar
    Stephen Bell

    Excellent post – thank you for this information. I have a question that I am not sure is clear from the post.

    Do you have any pre-existing office installation in your environment? We are trying to do this same thing – however, our clients are running a Click to Run installation of Office 2013. If I double-click the powershell script we have -it installs just fine. When I add it to the GPO I get an error. If I first uninstall office then install the new version, it seems to work fine. One potential hangup with this is – after this installation, Office 2016 is not associated with the user account Office 2013 was, and prompts the user to authenticate to their office 365 account. Ideally, I would love for this auth prompt to not happen.

    Any tips you could provide would be appreciated.

    1. Brian Reid avatar

      You can use ADFS to do your Office 365 auth. That will not require the user to enter a password for Office. They though might need to enter a username first.

  6. Adam avatar

    We are deploying Office 2016 via the cmd script above and it’s working great! My question is with the set LogLocation=\\server\InstallLogs\Office2016 line. Do you know of a way to generate a new email and send the log file to a mail in database?

    1. Brian Reid avatar

      So you could migrate it to PowerShell and use the Send-MailMessage cmdlet or call a PowerShell script or any other email sending script to pick up the created file as an attachment

      1. Adam avatar

        I will test that. Thank you!

  7. Khalid avatar

    Hi, there is no setup.exe in the downloaded binaries. Also are you sure the paths you have here are correct? sometimes you use \\server\office2016 and sometimes you use \\server\software\office2016 ? Also where is the location of the Office365ProPlus folder and what it will contain? Can you please add pictures to how the folders look like to make more clear …. I am confused now. The process will work only if we copy o2016 from DVD not with the downloaded version with the command as there is no setup.exe

    1. Brian Reid avatar

      Hi. There is no DVD for the version of Office 2016 that comes with Office 365. This document is for the Click to Run version of Office and not the MSI installed Volume Licence version.

      For reference and to cover all the asked questions. The setup.exe does not come with the Office download – it comes with the Office deployment kit. Separate download is mentioned in blog. Paths fixed in the blog.

      1. Khalid avatar

        Thanks, the installion is starting and seems still need to connect to the internet to get some files, but the installion hangs and the log file is showing the below error so many times:

        Nexus Transport a426j Unexpected MsoGetRemoteHostNetworkStatusWithUrlType failed {“RemoteHost”: “”}

        and will keep trying on this for hours, the installation was aborted after almost 6 hours. Any idea what the issue is?

  8. Brian Reid avatar

    I will assume that you have opened your firewalls to all the listed locations that the Microsoft Cloud services require access to for the Office application? You can find the list at This lists all the URLs (and IP’s if you don’t have a URL filtering firewall) that need to allow connections through and all URL’s that you should not be filtering or authenticating on your proxy server.

    From this URL list you can see that is accessed from the client computer where Office 365 ProPlus is running.

    1. Brian Reid avatar

      MsoGetRemoteHostNetworkStatusWithUrlType usually means the path to the installation source on the network is wrong. So check everything. First if you have spaces try and get rid of them. If you cannot, try again and get rid of them – it will save a lot of issues. So I recommend \\\dfsroot\softwarelibrary\office\etc over “\\\dfsroot\software library\office\etc”. If you change the path to remove spaces make sure you update the installer path in the script and the SourcePath and UpdatePath in the XML file.

      Check that the setup /configure pathtoxml.xml is correct as well – try and enter the path in Notepad as a file to open. If you have a small typo then the file will not open. Again check the path to the XML for spaces as well. For example setup /configure \\\dfsroot\softwarelibrary\office\2016.xml is better than setup /configure “\\\dfsroot\software library\office\2016.xml” (note the quotes go around the file name and not the entire path to the script.

      And of course, in the script if you add quotes it is very likely to upset other quotes – so best to avoid spaces altogether (did I say that already?)

  9. Alexandru Hera avatar
    Alexandru Hera

    Hi Brian,

    Its a great tutorial, and I’m working on it. But for some reason I get error code 5.
    Could you know that that means? and tell me what am I doing wrong?

    Best regards,

    1. Brian Reid avatar

      5 means access denied

  10. Alexandru Hera avatar
    Alexandru Hera

    Worth to mention that the users in the domain don’t have admin rights. 🙂

    1. Brian Reid avatar

      Correct – that is why you use Computer Startup scripts to install it. Scripts that run here get admin rights. If you run the script as the user it will require admin rights.

      1. nathan taylor avatar

        I too am getting error Code 5. I’ve checked and I don’t think it’s access denied on the shared folder with the install file. It’s running the script far enough to write the error to the log file. It’s interesting because when I run the batch file manually I get a UAC Prompt and it installs properly. Calling it via Group policy results in error code 5.

        1. nathan taylor avatar

          After playing wtih the permissions on that folder. I am now getting error 1602 rather than error code 5……

          1. Brian Reid avatar

            1602 means “user cancelled installation”

        2. Brian Reid avatar

          Group Policy runs as a system account. Make sure permissions allow everything (users and computers) to read from the share

  11. Alexandru Hera avatar
    Alexandru Hera

    Hi Brian,

    I had it working on my test environment, but now I cannot see why it doesn’t work. I get no log for about the installation process on workstations in the domain.
    Could you tell me please with who do I share the Office2016 folder? I did Domain Users

    And the policy should be applied to authenticated users or computers as well?

    Best regards,

  12. Kamlesh Bhatt avatar
    Kamlesh Bhatt

    Hi Brian,
    Thanks for posting such post, i have configured successfully deployed office 2016 via startup scrip. but if office 2013 is already installed in systems in that case we are not able to deploy 2016 .
    as users are using 2013 and i am planning the deploy 2016 in background .

    please suggest ?

    Kamlesh Bhatt.

    1. Brian Reid avatar

      You need to upgrade. 2013 and 2016 cannot coexist. Therefore you cannot deploy in the background. If 2013 is not running and you have a 2016 setup running it should upgrade your install. If 2013 is running the install/upgrade fails.

  13. Jeff Rodgers avatar
    Jeff Rodgers

    This looks fantastic… I am however receiving an error in testing. I’ve run it from an Administrative Command Prompt.
    The script ends with “Setup Ended with error code -2147418113”
    Any ideas?

    1. Brian Reid avatar

      I have lots of info for that error code. In Err.exe (Microsoft download, Exchange Server Error Reporting Tool, though it does everything and not just Exchange), that number comes up lots (and lots). Generally it means “E_UNEXPECTED”, so its an unexpected error – not that it helps you much. It could mean “MSG_NO_MEMORY” regarding certificates, “MSG_BAD_REGISTRY”, “MSG_TIMEPROV_ERROR”, and “ERROR_INVALID_FUNCTION”. So I would take another look at the script and make sure it contains no typo’s – that’s a common issue with downloading scripts from the internet – check the quotes etc. and make sure they work.

  14. Dave Bragg avatar

    Thanks for sharing this, Brian. I followed the steps closely and have it working perfectly in my test OU, with 2012R2 server and 8.1 clients. Next week, I shall be using it on our production OU for some new installs!

  15. Alexandru Hera avatar
    Alexandru Hera

    Hi again,

    I’ve made it work, but am I still having some issues.

    For example, in my scenario, if I manually uninstall office from a user computer, and reboot, the office will not be automatically installed again, like in case of new computers.
    Is it possible that manual uninstall leaves some registry and other data in the user’s computers?
    I also don’t see the logs with the computer’s name and installation status.

    Are there any alternatives to detect if office is installed?

    Worth to mention that the guy before me installed Preview 3 of Windows Server 2016.
    I’ve just started for 4 weeks now as a Junior System Admin, and nobody in the company is helping me, so please, I would appreciate if you could give some advice Brian 🙂

    1. Brian Reid avatar

      The script rings looking for a registry key. If not there, then there software installer runs. I have not checked the presence of the key after uninstall, but the key is a click to run key and not an Office key, so it might remain behind with an uninstall.

      So either change the batch file to query a key that is not present in both a new and uninstalled computer and let the installer run again

  16. Harry avatar

    First off, let me say this article has been awesome. Thank you for the work you put in to help us out.

    However, I am having the same problem as Alexandra has. I cannot get it to re-install after a manual uninstall. I have deleted the whole 16.0 registry key, but still no go from the GPO. I can manually run the CMD file and it works (of course it asks for admin permissions), but the GPO should not need since the script is in the computer configuration of the policy.

    Is there some other “switch” that gets triggered within the GPO that prevents it from running again?

    1. Brian Reid avatar

      So I have not tested this script with uninstalls (or indeed anything fancy). The script just looks for the lack of a registry key and if the key is not present assumes the product is not installed (this is of course one of many ways to test for the presence of an application, it may not be the best way!). If key not present then it starts the installer. Of course the installer may fail here independently of any registry key. If the key does not exist, the installer will start. The installer will do its own checks and fail or complete. These checks will be logged in the the Office logs in %temp% (if you allow logging in the config file that is). Therefore in your case, though you have deleted the regkey, the installer is making its own decisions on what to do and if failing independently of this simple script.

  17. Chris avatar


    I have about 500 end users and the problem I have is that my staff randomly installed both 32 and 64 bits versions of Office365 2013 on all of our 64 bit machines. Is it possible for the script to determine the BIT version installed and upgrade Office accordingly?



    1. Brian Reid avatar

      It would be possible. I would look for an already installed file rather than registry key and base the determination of what to do on what you find.

  18. Anders Nielsen avatar
    Anders Nielsen

    Good article! What if you would like to change the content of the 2016 deployment, let’s say you want to remove Access 2016 and add Project 2016? You need to run the installation again with a modified configuration.xml I guess?

  19. Brian avatar

    Do you know how to modify the script to also check for non-click2run installs? C2R won’t install on a PC which already has an MSI version installed, so we want to avoid running the installer.

    1. Brian Reid avatar

      Sorry no. This script is not a replacement for a full deployment tool like SCCM.

  20. Pardip Singh avatar
    Pardip Singh

    Hi Brian,

    First, thanks for posting this useful info.
    So my questions is regarding upgrade the users from office 2013 to 2016. Is there way I can keep the office 2013 while office2016 is installing. Or how can I remove office2013 and install 2016 using script. Any help will be appreciate.


    1. Brian Reid avatar

      You cannot keep both. Its a upgrade. C2R install does not allow for both to be installed at the same time.

  21. Eric avatar

    I want to create a startup script to install a software but I have never done it before its outside my field. please assist with pre-created script that will run via GPO

    1. Brian Reid avatar

      Hi – you can give the south African office a call. Details at and they can let you know the costs for this work.

  22. Kenshin avatar

    Hi Brian,

    Would like to ask for your help. im currently installing Skype for Business Entry Retail 2016 via GPO right now, the GPO execute and install but the logs doesn’t work? none log files stored in the logs folder. here is my script:

    IF EXIST “C:\Program Files (x86)\Microsoft Office\root\Office16\lync.exe”
    (goto End)
    else IF EXIST “C:\Program Files (x86)\Microsoft Office\root\Office15\lync.exe”
    (goto End)
    else IF EXIST “C:\Program Files\Microsoft Office\root\Office16\lync.exe”
    (goto End)
    else IF EXIST “C:\Program Files\Microsoft Office\root\Office15\lync.exe”
    (goto End)
    else IF EXIST “C:\Program Files\Microsoft Offic\Office16\lync.exe”
    (goto End)
    else IF EXIST “C:\Program Files\Microsoft Office\Office15\lync.exe”
    (goto End)
    else (goto Install)
    REM Set DeployServer
    set DeployServer=\\\odt\
    REM Set ConfigFile
    set ConfigFile=\\\odt\configuration.xml
    REM Set LogLocation
    set LogLocation=\\\odt\logs
    REM Start Install
    echo %date% %time% Setup started. >> %LogLocation%\%computername%.txt
    start /wait %DeployServer%\setup.exe /configure %ConfigFile%
    echo %date% %time% Setup ended with error code %errorlevel%. >> %LogLocation%\%computername%.txt

    1. Brian Reid avatar

      Sorry – I cannot help you troubleshoot scripts in this blog. There is no guarantee that things like quotes or paths etc. are correct in the script you are running and I cannot see your environment from here and so cannot help. If you want help then we can provide support on an hourly basis to assist and then we would arrange remote or onsite access to work through the issues you are having. Please give us a call.

  23. Csaba avatar

    Our company has a license for Office 2016 Professional so I have a MAK key for this product. Is it possible to use your ‘Click To Run’ solution with this MAK key? I installed the Office as you wrote in this tutorial but after installation when I tried to change the product key I get an error message. I think this Office version isn`t compatible with our MAK key.

  24. Henry avatar

    Thanks for putting this together, however, setting up the GPO policy to run as a startup script against the test OU is not working. Please advise

  25. Csaba avatar

    Hi again!
    I send you this comment on august 8:
    Our company has a license for Office 2016 Professional so I have a MAK key for this product. Is it possible to use your ‘Click To Run’ solution with this MAK key? I installed the Office as you wrote in this tutorial but after installation when I tried to change the product key I get an error message. I think this Office version isn`t compatible with our MAK key.
    Can you help me? I am waiting your answer.
    Thank you!

    1. Brian Reid avatar

      No you cannot. You need to use the MSI installer and not the Click to Run installer to licence with MAK.

  26. Harsh avatar

    Hi Brian,
    When I run the script, Office does not install because of this- “error code 0-1008(0)” ( Is your internet connection working? Do you have enough free space on your main hard drive?). The log file reads, ” Setup Ended with error code -2147418113″. How do I get rid of this?
    Thank you

    1. Brian Reid avatar

      Hi – try to troubleshoot your installation, as -2147418113 means unexpected error. Also check that your installation setup.exe /configure XML file works and troubleshoot the script and make sure that works.

  27. charles johnson avatar
    charles johnson

    Ok, i am having a little trouble getting this to work. I would love it if you could provide any answers to the following questions.

    1. should this startup script be a Computer Policy or a User Policy ?
    2. in the script should i be removing all the REM and numbers?
    3. set DeployServer=\\ServerName\PATH\ ….. should this be pointing to the path where the setup.exe file is ? Or should it be set to the path where the software is downloaded ? Also if it is the path where the setup.exe lives should i be pointing directly to that file ? like \\servername\path\path\setup.exe ?
    4. last but not least the set ConfigFile=\\servername\path\path\config.xml is this correct? or should it be setup.exe\config.xml?

    I can run the Click to Run fine if i map a network drive and invoke the install process manually. I would love to get this logon script working and save me a lot of work.

    Thanks for any help in advance.

    1. Brian Reid avatar

      Hi Charles, its a computer startup script as written in the post above. The REM’s – no leave them. The numbers – don’t copy and paste the script from the webpage, but click the icon to the top right of the code to view the code and not what is rendered in the webpage. The numbers are for reference and are not part of the code.

      The DeployServer path should be set to a network-accessible location containing the Office source files. These files when downloaded with setup.exe always create a office\data folder path. You are pointing to the root folder of this path that contains the Office subfolder. This is the same folder that you enter into the XML file to download Office binaries into.

      Finally, the script is correct. The ConfigFile setting goes to the XML file and not setup.exe\config.xml as that is not a valid path. Line 26 in the code reads “start /wait %DeployServer%\setup.exe /configure %ConfigFile%”. This is the line that does the work. It runs setup.exe from the DeployServer path (so that is dropped into the root folder that you download to) and then /configure switch is run to tell Setup where the XML file is.

      Of course the path needs to be valid, the XML needs to be correct. This blog post does not cover getting these right, as that is part of Office deployment generally. This blog covers automating an already working installation and for that understanding of scripting files, exes and paths is necessary.

  28. Ell avatar

    27/09/2016 16:43:51.93 Setup ended with error code 0.

    Any ideas of the cause?

    1. Randal avatar

      0 = Success

      1. Brian Reid avatar

        0 means reg key was found, so product is installed, therefore do not install it again

  29. Dave B avatar
    Dave B

    Great tutorial but a little confused;

    Create a software deployment file share that you have read/write access to and everyone else read only and create a folder called Office365ProPlus inside this to store the binaries.

    Ok – \\server\Software\Office365ProPlus

    Create a second file share that everyone has read/write access to (or CREATOR OWNER has write so that only the creator of the file can write it to the share and others can read or not see it at all). Create a sub folder in InstallLogs called Office365ProPlus.

    I’m assuming you mean create \\server\Software\InstallLogs and then a subfolder inside of there call Office365ProPlus?

    e.g. \\server\Software\InstallLogs\Office365ProPlus

    In my demo these two shares and subfolders are called \\server\Software\Office2016 and \\server\InstallLogs\Office2016.


    What about the Office365ProPlus folders?

    1. Brian Reid avatar

      Office365ProPlus is just an example as the name of the software you are installing. If you are on the Small Business SKU of Office 365 you might want to call it Office2016Business, it does not matter as long as the same named folder is referenced in the script and in the XML file and in the setup /download to pull down updates. Get the folder names out of sync and this does not work. Best suggestion is copy the script and use the names I use – then you need to change nothing apart from the server name.

  30. Carlo avatar

    Hi Brian,

    I am also receiving an error code of 1602 when the device hits the logon screen.

    I have tested my policy and the modified script you provided in my lab and it deploys using a VM copy of our SOE and displays error 0. The install appears to have successfully deployed.

    It is once i test the deployment on a production machine that this error occurs.

    I have granted “everyone” read/write on the share. Initially i thought it was office iteself launching in the users context causing the install to abort however if left unattended at a logon screen the same error is thrown.

    I have reviewed the deployment logs but there is nothing useful here.

    Any suggestions would be great 🙂

    1. Brian Reid avatar

      1602 means user cancelled the installation. Not sure how that helps you here, but that is what it means.

  31. Tim Scott avatar
    Tim Scott

    I got the script working, but it appears that the registry key check isn’t working. In other words, it tries to install Office 2016 each time the script runs. It also apparently uninstalled Office 2016 for one of our users. Any ideas? We are deploying it to Windows 10 Machines.

    1. Brian Reid avatar

      Run the reg query line manually and then %errorlevel% and see what you get. Check if the reg key exists. It might from a previous attempted install. It might be for your install and version you need to find a key that is not there until it is installed. The key in the script did that for me, but that might have changed since I wrote the post.

  32. Micah MacDonald avatar
    Micah MacDonald

    I have tried this with mixed results. As far as I can tell I have done everything correct but the script never runs. I can access the network share form the client computer but running the cmd file from there does nothing whether I run it normally or as administrator, but if I open a command prompt and paste in the contends of the cmd file(control A to get it all then copy paste) then the procedure kicks off no problem. Any thoughts?

    1. Brian Reid avatar

      The batch file under a GPO runs under the computer account, not a user account. Make sure permissions are such that computers can write to the share and not just users.

  33. Jeff avatar

    Hi Brian,

    Thank you so much for taking the time to get this all written up. I was able to follow your instructions, but am having one tiny issue. The batch file I created for the GPO to install Office works great when run manually. Program installs, log file is created, no problems! However, when I create and test the actual GPO, using the same batch file at startup, it does not appear that the log file is being created. Office is still installing, if not already present, but the log file never gets created. Any idea what I could be doing wrong here?

    1. Jeff avatar

      Nevermind! I had forgot to throw CREATOR OWNER permissions on my InstallLog share. All good now! Thank you again fo such an excellent write up!

      Best wishes,

  34. AJ avatar


    I’m attempting to upgrade Office 365 2013 to 2016 via SCCM. I can successfully install by making the Application available within the Software Center. However, when making it required and assigning it to my test collection I get a failure at 65%. The error code returned is 17004. I have successfully installed via the Software Center multiple times. My application is set to download and run locally from the client ccmcache folder. A lot of threads suggest using GPO to perform the upgrade instead of SCCM. Any idea why I can install from the Software Center but not when it is a required application?

    1. Brian Reid avatar

      Are you using SCCM to remove the old version of Office first? 17004 usually means “cannot upgrade”

  35. Drew avatar

    Hi…when I run the CMD manually it runs fine. When I try from GP it does not run, GPresults show the policy is applied. Any ideas

    1. Brian Reid avatar

      No sorry – thats next to impossible to troubleshoot from a blog post comment!

  36. R W avatar
    R W

    Hi Brian – Thanks for posting these two articles on deploying Office 365 via GPO. I was able to build on this script, testing for and removing Office 2007 and Office 2013 prior to installing Office 2016. Works great, thanks again.

    1. Brian Reid avatar

      Thanks – nice to get feedback. Glad it works

    2. shewa avatar

      Hello R W

      I have problem, at the moment office 2007 is installed on our client machines, now we decided to migrate to office 365 and i tried to try this script and install office 365 and remove 2007, but so far no luck, can you please put some light on the steps that you did or if you can share the scripts. thank you

      1. Brian Reid avatar

        You would need to share what you have done, what errors you get, did it work when you tried without a script etc.

  37. Shaun avatar

    Hey Brian, I’m testing your process and find that my machines are not waiting for the setup.exe task to complete before bringing up the windows logon screen and allowing me to log in. Do you see the same behavior? Reason I ask is the install is failing when trying to deploy using group policy as described in your article, but the script runs fine if I log in and run it manually as admin user.

    When I log in after trying to deploy using group policy, I see the log file created by the script (“Installation started…”) and I see various click2run log files indicating the install had started, but I see various errors in those logs including this one: “upgrade failed with error code 17002”.

    Regarding that error, I read elsewhere that I have to *wait* for the installation to complete before logging in to the machine but that hasn’t worked, plus I assumed that was the point of the “start /wait” command in your script.


    1. Brian Reid avatar

      If the script, which has no real error handling (as its a basic batch file) errors and the setup.exe fails to run for any reason, then start /wait does not matter as the setup.exe has finished and the login process starts. Your error says upgrade failed – you cannot upgrade Office 2016 C2R with setup.exe, you have to uninstall Office 2013 C2R first.

  38. Randal avatar

    Line 22 should start with “if NOT %errorlevel%==1 “

    1. Brian Reid avatar

      The code is correct. If reg query %errorlevel% returns 1 then the key was not found, the product is not installed, therefore go to the install section of the code

  39. Randal avatar

    Ah, it looks like an uninstall does not remove that package key from the registry. I had a previous install.

  40. KenneyDe avatar


    Do you have a list of error codes? I received a 1603 error on a test i was doing with this.


    1. Brian Reid avatar

      1603 is “Fatal error during installation”. This is got from the err.exe tool, which I think used to be called the Exchange Server Error Codes tool (or similar) but contained all the Windows errors codes as of abut ten years ago – but error codes are reused for similar things so still a useful tool

  41. […] Installing Office 2016 Click To Run Via Group Policy […]

  42. Josh G avatar
    Josh G

    Once the ‘UpdatePath’ is set and the ‘UpdatesEnabled’ is set to True, do users still have to manually click Update Options->Update Now within one of the products in order to get the newest update or will it automatically see the update and install it? It appears I can only get it to update when I manually do this whereas I am looking for Office to recognize when there is an update and install it automatically. This is for Office 2016.

    1. Brian Reid avatar

      You need to wait a while before it will automatically do it. First it checks each Tues and Sunday for if an update is available at the UpdatePath. Then it downloads it. Then when that is complete (using BITS, so its not a network interrupting, but a slow and steady download) it will alert you via the Backstage area (under File menu). After a while, it will draw a banner across the top of the app to tell you. Once it is downloaded, all you need to do is restart all the Office apps for the update to process. So for example, rather than clicking update you restart the PC (which restarts all the Office apps) it will update on the next time you start the first Office app. If you never restart all Office apps together (i.e. never reboot) then you will go through the backstage alert and then the banner alert

  43. Jakob Pittman avatar
    Jakob Pittman

    Hi Brian,
    I am having issues with the script running as a start up script. it will run as a logon script but when i change it to startup i get either error code 2 or error code 0 in the log file. can you please let me know what these code mean.

    Here are the codes im using. can you please let me know if there are any glaring issues
    The pushD command was not working for me so had the script map the drive then just change to it.

    REM *********************************************************************
    REM Set DeployServer to a network-accessible location containing the Office source files.
    set DeployServer=\\xxxxxxxxxx\Office2016_Deploy
    REM Set ConfigFile to the configuration file to be used for deployment
    set ConfigFile=\\xxxxxxxxxx\Office2016_Deploy\configuration.xml
    REM Set LogLocation to a central directory to collect script log files (install log files are set in XML file).
    set LogLocation=\\xxxxxxxxx\Office2016_Deploy\Office2016_InstallLogs
    REM *********************************************************************
    IF NOT “%ProgramFiles(x86)%”==”” (goto ARP64) else (goto ARP86)
    REM Operating system is X64. Check for 32 bit Office in emulated Wow6432 registry key
    reg query HKLM\SOFTWARE\WOW6432NODE\Microsoft\Office\16.0\ClickToRunStore\Packages\{9AC08E99-230B-47e8-9721-4577B7F124EA}
    if NOT %errorlevel%==1 (goto END)
    REM Check for 32 and 64 bit versions of Office 2013 in regular registry key.(Office 64bit would also appear here on a 64bit OS)
    reg query HKLM\SOFTWARE\Microsoft\Office\16.0\ClickToRunStore\Packages\{9AC08E99-230B-47e8-9721-4577B7F124EA}
    if %errorlevel%==1 (goto DeployOffice) else (goto End)
    REM If 1 returned, the product was not found. Run setup here.
    echo %date% %time% Setup started. >> %LogLocation%\%computername%.txt
    net use y: \\xxxxxxxxr\Office2016_Deploy
    start /wait %DeployServer%\setup.exe /configure %ConfigFile%
    echo %date% %time% Setup ended with error code %errorlevel%. >> %LogLocation%\%computername%.txt
    REM If 0 or other was returned, the product was found or another error occurred. Do nothing.

    Thanks for this code it is a great help.

    1. Brian Reid avatar

      What permissions do you have on the install folder. It needs to be as above, as start scripts run in the context of the computer account and not the user account aka logon scripts. Permissions need to be EVERYONE read and not DOMAIN USERS read for example

      1. Jakob Pittman avatar
        Jakob Pittman

        It Ended up being an issue with the XML file i have resolved it. Now i am getting a new problem. one that you will most likely not be able to assist with. I am just hoping that you are someone else reading this has encountered the issue before . After I apply the script to a computer on my domain that computer is then unable to boot. it gets stuck at the black screen with spinning dots( no windows logo) i am certain it is a driver issue as i am able to boot in safe mode. Hoping someone he had this issue and found a fix for it. Thanks.

  44. Marek avatar

    Thank You very much Brain for this excellent script – it made our installation flawless !!!! :):):)

  45. Frank Lane avatar
    Frank Lane

    2. “You cannot run software with elevated installation rights, as the setup.exe shells out to other processes to run the installation (the officeclick2run.exe service).”

    Does this mean the installation will not work unless the user is a local Administrator on the workstation with permissions to install software?

    1. Brian Reid avatar

      Yes – the person running the initial installer needs admin rights. This is why we have this GPO script, because GPO scripts run in the context of the computer account and not the user logging in.

  46. Nuno avatar

    Hello Brian,
    I am having an issue where the client machine recieves the policy and run the scrip, but the installation dont progress. The log file have the “setup started” message and i can see the process setup.exe in the resource monitor but the installation never ends.
    Can u give me any advice?

    1. Brian Reid avatar

      If the officeclick2run service is installed and started by the script (which is all that the above really does), the C2R service then installs Office based on the settings in the XML file. If the Office installer is failing it is logged to C:\Windows\Temp

  47. EddieV avatar

    Hello I have tested on my account that has admin rights and works flawless, but on a domain the user the script initiates, but they get prompted by the UAC for admin credentials to install. I have applied every permission that is needed to the file share with files and they still get prompted. Any suggestions? thanks

    1. Brian Reid avatar

      The script is designed to run via Group Policy under the Computer startup scripts. Computer startup scripts run with elevated permissions as this is needed for the installer. The installer installs the Click2Run service and the Click2Run service is what installs and upgrades Office. Therefore you do not need computer startup scripts to upgrade office, but you need them to get the service installed on the machine. So what you see if you just run the script is correct – just running the script and you need to provide elevated permissions

  48. Jonas avatar

    Install .cmd script isn’t showing up for me.

  49. Jonas avatar

    Found the _script but it doesn’t seem to run on my test VM, Gpo is updated and the _script gets downloaded to the local sysvol of the local computer but when I run it just blinks quickly.

    Its a brand new windows 10 install just joined to the domain.

    1. Brian Reid avatar

      Standard troubleshooting for this is to run the script from inside a cmd prompt on the client in question and see what it does. It will not disappear quickly if run from the console, but will if double clicked. Then after that check the logs if it gets as far as running the Office installer

  50. Chuck avatar

    We deployed O365 in this manner 10 months ago, and clients were getting updates from Microsoft(Monthly Channel). We want to change the channel and now exclude the Teams app. If we modify the cmd file so that it re-reads the config.xml, it then re-installs the old version that we had on the network for the initial install.
    Are we not able to change the configuration without re-installing? Do I need to ensure that my downloaded Office Data is at the latest client update version each time I need to make a config change? I’m just trying to understand the standard process here and I can’t find proper documentation for a situation like this. Any help would be appreciated.

    1. Brian Reid avatar

      The config file controls the initial installation and not any of the updates. Therefore when Microsoft add Teams to the update, you will get it automatically. When Microsoft add Teams to the installation, you can control it by excluding it in the config. To avoid removing and reinstalling, you can via the GPO set Teams not to auto-start when the user logs in. Then you can have Teams installed but never prompted for use and so the likelihood of the user finding it and running it is considerably reduced.

  51. B Dunn avatar
    B Dunn

    from the script i presume it doesnt detect if its already installed and then doesnt run the installer if it detects its already installed?

    1. Brian Reid avatar

      I think you mean “from the script i presume it


      detect” – and yes it does. It detects if the C2R installer is installed. If it no more intelligent than that – so if C2R service is installed but the installation fails, it will need fixing manually

  52. Marc avatar


    I am using this very process and it seems to work well, but I do have a question about whether there is any way to display a notification to the user’s screen similar to “The latest version of Office is being installed on your computer, please don’t open any Office applications during this time.” and then “Your computer has been upgraded to the latest version of Office 365, please press any key to continue…” after the install is complete? It seems I can do this when running the the script manually, but cannot display anything to the user when the GPO startup script is running.

    Please let me know your thoughts.

    1. Brian Reid avatar

      The script is a computer based startup script, so it happens before login. That said, if the user is logged in and they start Office that’s fine – it’s Click 2 Run installer technology which virtualizes the installation and does just in time install – so if the user opens Word, the installer will ensure all the bits needed to start Word are installed whilst the user is on the splash screen and then install the rest of Office and other bits of Word not required whilst the user is using the app just fine.

      1. Marc avatar

        Thanks Brian, what I am more concerned with is that the user would start their computer, login and immediately open an Office 2016 program (Outlook) while the Office 365 installation is occurring. I’m assuming that the O365 install would just shut down the Office 2016 program, but that’s why I was hoping to provide some user feedback during the install to help avoid some frantic helpdesk calls that their Office software just crashed. Let me know your thoughts.

  53. Diakhate avatar

    Hi MR REID
    Im deploying 64 bit version of officein 64 bis system using your script. what will be the registry key ?

    1. Brian Reid avatar

      The script already checks for bitness and looks up the correct registry key.

  54. Adrian C avatar
    Adrian C

    Will this reinstall with every reboot, or will it check?

    1. Brian Reid avatar

      It will check on each run of the script if the C2R service is installed.

  55. Brian Kemp avatar
    Brian Kemp

    We are looking at installing Office 365 via group policy. It is my understanding that updates will require local admin rights to be installed. If that is the case can your script be modified to check the version of the installed office vs the one in the network share for installation?

    1. Brian Reid avatar

      The initial installation of Office (which is covered in the blog post) installs the installer service. The installer service then installs Office. Updates are covered by the installer service (Microsoft Office Click-to-Run Service, or ClickToRunSvc, or OfficeClickToRun.exe in Task Manager).

      You do not need to modify the script to check for updates. The script checks to see if Office installer service is installed. If it is installed it assumes all is good with the world and that you have Office on the machine. The installer reads the XML file to get the initial installation and update settings. As long as you include update settings in the XML file then Office will download from the internet or your file share the latest available version. If you use a file share then make sure that you keep it up to date. If you download from the internet be aware that Windows 10 supports technologies based on torrent downloads so that the content of the 1Gb+ download can be shared across all machines on the LAN and that only the bits needed for the update are downloaded, so not every machine downloads 1Gb+ Office update a month (its considerably less than that). Therefore updates via a fileshare, though I recommended them in the original blog post, I would not recommend them now unless you are a desktop (not laptop/portable computers) based company and users do not work remotely. Fileshare downloads to laptops when off network will not work, but internet download will always work.

  56. OliverJ avatar


    I have found that when a PC has a version of Office 365 ProPlus Click To Run and you uninstall it (like to swap from 64 to 32bit or uninstalled by a user) it leaves behind the registry key HKLM\SOFTWARE\Microsoft\Office\16.0\ClickToRunStore\Packages\{9AC08E99-230B-47e8-9721-4577B7F124EA}

    this means when the PC reboots the logon script believes the software is still installed and closes.
    Manually deleting the reg key means the script runs and installs on next reboot.
    Is there a different reg key that should be monitored instead to resolve this issue?

    1. Brian Reid avatar

      Not that I am aware of. This blog is to provide a very simple was of doing the deployment without lots of tools. If you are managing an uninstall and reinstall or version bitness upgrade then use a toolset such as Microsoft Endpoint Manager. To change bitness of a version though you do not need to uninstall – see

Leave a Reply to Marc Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.