Automating the Outlook Client Installation

Have you ever had the need to install the CRM Outlook client to a new batch of users? Or had a CRM upgrade and wanted all of your users to have their client upgraded as well?

Well, you have a few different options:

  1. Have someone from the help desk go to every workstation to download, install, and configure the software. This would be a preferred choice for a very small user base. But when you have 10, 20, or hundreds of users, it becomes very costly.
  2. Create an installation guide and send it to your users. Sometimes this is the best choice, but you will still end up spending a lot of hours supporting those users who are not IT-comfortable. And if your user base has varying versions of Microsoft Office (32-bit vs. 64-bit), they will have trouble finding the correct version they need to download.
  3. Perform an administrative install via GPO (group policy). This is often the preferred method and is covered here in depth, because it saves a lot of time and does not require extensive programming knowledge:
    The end result is that you can select users or workstations, who will then have an option in their control panel to install CRM. However, it does not allow you to push the installation and configuration to a group of users.
  4. Create an installation script via command line statements (batch file), which is what this blog will cover. The one advantage this had over option 3 is that you will be able to configure additional parameters, apply updates, and any other miscellaneous changes you want to add. It also allows for less user interaction in general for the full installation. However, it does require some basic command line prompt knowledge (sometimes referred to as DOS prompt). There is a lot of material out there that covers the basics of using command line statements:
    Installing the CRM Outlook client via command line works just as well by double clicking, or through a command prompt.

What should be included in the batch file?

Before beginning to create your script, first decide what are all the steps that you want to include. Can you assume that everyone who uses it will have all the necessary prerequisites needed for the installation? Probably not. So here are some basic overall items to include:

  • Check if Outlook is running before installation
  • Check if they have a valid version of Outlook.
  • Decide where the installation will run from
  • Adjust any power settings
  • Add any additional registry settings
  • Configure CRM to an existing org
  • Apply any service packs or update rollups


Before getting started, you will likely need a shared folder location that all of your users have access to. They will also need rights to be able to run a batch file from that shared folder. One potential benefit of this is that you may have an environment that users do not have local administrator rights to their workstations, but a script running from your network can run in elevated privileges. You can also run it in the user’s context, which becomes extremely helpful when we get to the step below of configuring to a CRM org.

The steps shown in this blog detail an installation done from a shared drive. If that does not work for your users, another option will be to create the script and place it, along with the Outlook Client installation files, in a location that someone can download it and run it, but you will have to modify some of the steps below.

Configuration File

You will also need to create your config file, which is pretty straight forward to do. When you install CRM, in the installation folder, you will see a file called default_config.xml. You will need to edit it to add any orgs you want to configure to.

Here the deployment section in the file. You will need to it the server URL and the org name. You can also configure additional parameters. In our example below, we have created our config file and named it crm.xml.


Check if Outlook is running

If you try to install, configure, or update CRM for Outlook while Outlook is running, you may run into problems. So it is generally suggested to have Outlook closed while this is happening. Therefore, the first thing we may want to add is a quick check for running processes, and if Outlook.exe is running, then prompt the user to close it and retry.

@echo off
::begin check if Outlook is currently running

tasklist /fi “imagename eq outlook.exe” | find /i /n “outlook.exe” 1> NUL
if not “%errorlevel%”==”0” goto outlooknotrunning

echo Please close Microsoft Outlook before proceeding.

goto outlookisrunning


The key here is the tasklist command, that checks if outlook.exe is currently a running process by piping it through a find command. We also redirect the command output (1>NUL), otherwise it would still work, but it would display a less-than-helpful error message to the user.

The commands above would put the user in a loop that tells them to close Outlook, and then press a key to continue.

Where will the installation run from?

You can run the installation directly from the network drive. But that may be extremely slow for end users, especially if they are working from home on a VPN line. So to minimize network performance issues, our recommendation is to copy the installation files from a network, and do all the work locally on the user’s workstation. So for this purpose, we are going to create a folder in the user’s home directory, where we will copy the files to so we can install it from there.

set install-path=”\\mysharedserver\install_packages\CRM\files

echo Beginning CRM installation. This process may take up to 15 minutes. Please do not open Microsoft Outlook until the installation has completed.

::create local temporary folder
md %userprofile%\outlook-install-temp
cd %userprofile%\outlook-install-temp

Here, we are setting the installation path directory since we are going to be copying files from there in the next step, and we are also creating a folder called outlook-install-temp in the user’s home directory.

Check for a valid Outlook version

This may be the trickiest part of the entire thing. You may be in luck and have all of your users be in the same Outlook version, and same bit version, at which point you can skip this step entirely. But if you have a mix of Outlook 2007 (I hope not), 2010, 2013, and newer, with a mix of 32 and 64 bit … you are also in luck because we can help you!

First, from a high level, determine how do we want to specify which order of Outlook versions we should check? This may be important in scenarios where multiple versions of Outlook were installed, and old versions may not have been cleaned up completely. And we are checking for the bitversion for that specific Outlook version. For example, let’s say that our order will be: check bit version for Outlook 2010, and if it’s not installed, check bit version for Outlook 2013. If we don’t find neither Outlook 2010 nor 2013 installed, we are going to abandon the installation.

::begin bit check
echo Checking Outlook version.

::query Office 2010 bit key and copy to temp file
reg query HKLM\SOFTWARE\Microsoft\Office\14.0\Outlook /v bitness 1>bitcheck2010.txt 2>error2010.txt

for /f “tokens=2* delims= ” %%a in (bitcheck2010.txt) do set bitcheck=%%b

if %bitcheck%==x86 goto 32bit
if %bitcheck%==x64 goto 64bit

The reg command allows us to view the registry and check if a value exists. Combined with another for command, we can query that actual value and do a comparison, and determining whether we should proceed with a 32-bit or 64-bit install. If Outlook 2010 is not installed, then we don’t do anything yet, and proceed to the next step.

::did not find office 2010, now checking office 2013
reg query HKLM\SOFTWARE\Microsoft\Office\15.0\Outlook /v bitness 1>bitcheck2013.txt 2>error2013.txt

for /f “tokens=2* delims= ” %%a in (bitcheck2013.txt) do set bitcheck=%%b

if %bitcheck%==x86 goto 32bit
if %bitcheck%==x64 goto 64bit

echo No compatible version of Outlook has been found.
goto enderror

Now we do exactly the same thing, but instead query the Office 2013 hive, which is 15.0. If we find bit check exists, when we go to the appropriate version of 32 or 64 bit. If we do not find Outlook 2013 installed, then we abandon the installation (enderror).

Now the installation can resume on the appropriate bit version that has been installed. Our next step is to copy the files over locally.

::32-bit Outlook
echo Found 32-bit Outlook.
set config-path=C:\Program Files (x86)\Microsoft Dynamics CRM\Client\ConfigWizard
::copy install and config files
echo Copying network installation files.
copy /y /z %install-path%\CRM2016-Client-ENU-i386.exe .\client.exe
copy /y /z %install-path%\CRM2016-Client-KB3154952-ENU-i386.exe .\patch.exe
copy /y /z %install-path%\crm.xml .

goto resumeinstall

::64-bit Outlook
echo Found 64-bit Outlook.
set config-path=C:\Program Files\Microsoft Dynamics CRM\Client\ConfigWizard
::copy install and config files
echo Copying network installation files.
copy /y /z %install-path%\CRM2016-Client-ENU-amd64.exe .\client.exe
copy /y /z %install-path%\CRM2016-Client-KB3154952-ENU-amd64.exe .\patch.exe
copy /y /z %install-path%\crm.xml .

goto resumeinstall

Now here, we are doing a couple of things. Depending on whether we found 32-bit or 64-bit Outlook, we are copying the appropriate installation files to the local directory we previously created. We copy the CRM installation file, service pack 1 (covered later), and configuration file that we mentioned earlier. We also renamed the install and sp1 files in this step to a generic name. This allows us to do the remaining steps with the same command line, regardless of which bit version we are installing. Quick tip: you can use the /z command to specify a network copy. The benefit is that it adds a progress indicator while copying.

Installing CRM

Now it’s the easy part! Yes, the installation is actually quite simple. We basically do 2 thing: extract the contents, and then run the installation.

::extract file
echo Extracting installation files.
client.exe /quiet /passive /extract:.

::install using quiet switch and config file
echo Installing CRM.
“setupclient.exe” /q

Using the /quiet and /passive switches will install and extract it in the background without any user interaction, which is perfect for a batch file install.

Additional Settings

Do you need to set a HomeRealmUrl? (covered here:

Now is the time for a registry addition. For example, this command will set the HomeRealmUrl:

::configure login via Federation
echo Adding configuration for login.
reg add HKLM\Software\Policies\Microsoft\MSCRMClient /f
reg add HKLM\Software\Policies\Microsoft\MSCRMClient /v HomeRealmUrl /t reg_sz /d /f

What if you want to enable certain Internet Option settings, or add a domain to a trusted site? This is all doable here from the reg command once you find the correct registry location.

The CRM Outlook client will also perform better with high performance power settings. With powercfg ( you can set certain values in this script. Let’s say that for anyone installing CRM for Outlook, you want to increase the turn off hard disks when plugged in to 4 hours. This is doable with one line:

powercfg /change disk-timeout-ac 240

You can also setting additional powersettings if your company has a standard powerplan, by grabbing the correct guid through powercfg.

Note: another setting that is recommended is to turn on cached Exchange mode. However, we generally recommend setting this through group policy ahead of time instead of scripting it, since it could lead to unrelated Outlook issues.

Service Pack 1

We’ve already copied the service pack 1 (renamed to patch.exe) from earlier, so now let’s apply it, by first running an extract command, then running the executable.

::install service pack 1
::create patch folder for extraction
md patch

echo Extracting patch.
“patch.exe” /quiet /extract:patch
cd patch

::install with passive switch
echo Applying patch.
“crmupdatewrapper.exe” /passive /quiet

Once again, we use the /quiet and /passive switches to prevent user interaction while applying this patch.

Configuration Wizard

Now we go into the config path defined previously, and configure it with our config file that we created.

::config wizard
echo Configuring CRM organization.
“%config-path%\microsoft.crm.application.outlook.configwizard.exe” /q /i “%userprofile%\outlook-install-temp\crm.xml”

/q means run in quiet mode, and /I lets us specify the config file.

Remove your temporary files

So everything should now be working. However, earlier we created a temporary folder and added a bunch of stuff to it, and we no longer need it. So let’s get rid of it.

::delete installation folder
echo Deleting temporary installation files.
cd %userprofile%
rd /s /q outlook-install-temp

echo Installation and updates are complete.
echo Please restart Microsoft Outlook to finish the configuration.

And there you have it! If you were able to follow all of this, added all the files, created your script, and ran it successfully – great job! If you simply copied all the code here line by line and it works … even better! Just remember to send out the link to a smaller set of users first to catch any unforeseen problems before rolling it out to everyone.

For more Outlook related content, check out these blogs:

Happy CRM’ing!