Unattended installs of Sitecore

Edit: When I wrote this post I didn’t know what the SC_IISSITE_ID parameter to the MSI was for. Since then I’ve discovered what it does. And it turns out that it and another parameter not discussed here are quite important if you want to install more than one instance of Sitecore on the same machine. If you want to make use of the automated approach below, you should also read my more recent post about the parameters.

There are quite a few ways to install Sitecore. You can run the .exe provided from SDN, use the Sitecore Instance Manager, or write your own scripts to automate configuring the bits in the official zip files. But, having done a bit of testing, it seems that you have to be careful about the security settings when you’re using these different approaches. Whilst the .exe installer leaves you with a Sitecore instance that’s relatively safe to expose to the internet, SIM does not seem to make all the same security settings. It’s installs seem (by default) only suitable for private development instances. And the “roll it yourself” installs from Sitecore’s ZIP packages are only ever as good as you make them – miss a step and you might open a security hole.

With that in mind, I’ve been thinking about install automation – can I solve the problem of getting an unattended install to work from the .exe file?

The first thing I tried was running the .exe from the command line with the “/?” switch, just to see what happens. And what you get is this:


So the .exe is basically a custom automation wrapper. But what is it automating? Well in amongst those options is “/ExtractCab” – what does that give us?


Well that lot looks like some internationalisation settings, custom code for capturing data, some UI control theme data – and an MSI file.

That’s positive. MSI files are data for Microsoft’s transactional install system – they contain information about what to do during an installation – what files to deploy, and what custom steps to perform. And they explicitly support silent installations. But to get that to work you have to discover the “magic” values that the custom UI (our .exe file) are passing in to specify things like “where should the files be installed to?”.

Unfortunately finding that stuff out can be a bit of a black art. Microsoft do have some tools for opening MSIs and finding out what’s in them, but it involves installing a the Windows SDKs. But there’s a possible trick we could play here. Because the custom install UI is probably capturing some data from the UI and then executing the MSI Install tool as a child process, we may be able to steal the right set of settings by examining the processes while they’re running…

Any time I need to poke into the internals of Windows processes, my first choice tool is the SysInternals Process Explorer – it’s free and it can tell you all sorts of stuff. And one of the things it does is show you the tree of processes running at any point, and give you access to things like their command line parameters. And an added bonus is that you can run the Sysinternals tools straight off the internet, without any need to install them. Just click http://live.sysinternals.com/procexp.exe to start Process Explorer…

So if you run the .exe installer, answer all of its questions and then set the installation running, what you see in Process Explorer is:


You can see on the left that the .exe kicks off “InstallWizard.exe”  to capture all your install choices, and then that executes “msiexec.exe” which is the Microsoft tool for running an MSI installation. (Which should be installed on all Windows machines by default) And if you call up the properties dialog for the msiexec.exe process you can see the command line that is passed to trigger the install:

    /i "C:\Users\jeremy\AppData\Local\Temp\4\{6C7E5BDF-8FF9-4690-A3A5-CC2AE6312362}\exe\Sitecore.msi"
    /l*+v "C:\Users\jeremy\AppData\Local\Temp\4\SitecoreInstaller.log"

Bingo! There are all the secret parameters we need…

The “/i” parameter specifies the path to the MSI file you want installed. The next three control some of the behaviour of the MSI installer. All the ones starting with “SC_” or “SITECORE_” are the Sitecore install parameters. “INSTALLLOCATION” specifies the root path for the new instance. And finally the “/l*+v” parameter enables verbose logging. Note that the “/i” and “/l” parameters require an absolute path.

There’s just one other parameter you need to add to make this work. To perform a proper unattended install of Sitecore you need the MSI to show no UI when it runs. For that you just have to add one extra parameter to this command line: “/qn” which tells msiexec.exe to hide any UI.

The general command line reference for msiexec.exe is available on MSDN: http://msdn.microsoft.com/en-us/library/aa367988(v=vs.85).aspx

So now it’s a relatively simple tasks to write yourself a batch file, PowerShell script, or whatever other sort of install process you want. In theory you should be able to pass the parameters we discovered above via the command line of the .exe installer. However I’ve yet to get this to work correctly. So instead you can write your script to extract the contents of the .exe file from Sitecore, and then pass your preferred values into the parameters described above for msiexec.exe. Run that, and bingo – you’ve got yourself a new instance of Sitecore without any tedious clicking on installer buttons. And it should be as secure as if you installed it with all the clicking.

Using the parameters above, a batch file might look like:

"Sitecore 6.6.0 rev. 140410.exe" /q /ExtractCab
"msiexec.exe" /qn /i "%cd%\SupportFiles\exe\Sitecore.msi" TRANSFORMS=":InstanceId5;:ComponentGUIDTransform5.mst" MSINEWINSTANCE=1 LOGVERBOSE=1 SC_LANG="en-US" SC_FULL="1" SC_INSTANCENAME="silent" SC_LICENSE_PATH="C:\Software\PartnerLicense-2013.xml" SC_SQL_SERVER_USER="sa" SC_SQL_SERVER="localhost" SC_SQL_SERVER_PASSWORD="p@55w0rd" SC_DBPREFIX="silent_" SC_PREFIX_PHYSICAL_FILES="1" SC_SQL_SERVER_CONFIG_USER="sa" SC_SQL_SERVER_CONFIG_PASSWORD="p@55w0rd" SC_DBTYPE="MSSQL" INSTALLLOCATION="C:\Inetpub\wwwroot\silent" SC_DATA_FOLDER="C:\Inetpub\wwwroot\silent\Data" SC_DB_FOLDER="C:\Inetpub\wwwroot\silent\Database" SC_MDF_FOLDER="C:\Inetpub\wwwroot\silent\Database\MDF" SC_LDF_FOLDER="C:\Inetpub\wwwroot\silent\Database\LDF" SC_NET_VERSION="4" SITECORE_MVC="1" SC_INTEGRATED_PIPELINE_MODE="1" SC_IISSITE_NAME="Silent" SC_IISAPPPOOL_NAME="SilentAppPool" SC_IISSITE_HEADER="silent" SC_IISSITE_PORT="80" SC_IISSITE_ID="13" /l*+v "%cd%\SilentInstall.log" 
rmdir /S /Q "%cd%\SupportFiles"

It extracts the MSI, installs it with the parameters discussed, and then removes the temporary files it created.

There are a few caveats with this though:

  • Firstly, new releases of Sitecore may change the set of parameters above – so you may need to repeat the discovery process here for newer versions.
    (I’ve done this against the latest installer for v6.6 – but I’d be pretty confident that v7.x will require different parameters)
  • I’ve not exhaustively tested this – it may not work correctly if some pre-requisites of Sitecore are missing.
  • I’ve not worked out exactly what the SC_IISSITE_ID property above does – it’s possible the value for this is important in ways I don’t currently understand. So take care if you try to repeat this experiment.

6 thoughts on “Unattended installs of Sitecore

  1. When runinng the paramaters with with a bat file, it extracts the cab and shows the Windows Installer parameter window but doesn’t install anything. What might be the problem ?

    • If it’s showing some UI then there’s something wrong with the batch file you’re running, I’d guess. The example batch file is supposed to perform a silent installation – so it should show no UI at all.

      It’s not quite clear to me what UI you are seeing. When you say the “Windows Installer parameter window”, do you mean the first image in the post above, or do you mean the UI where the installer asks what instance name / database connection to use?

      If it’s the first image above, then my guess would be that the error is in the line of the batch file that’s supposed to extract the cab file, and it’s continuing on to show its normal UI.

      If it’s the bit of UI that asks about database connections and instance names, then my guess would be that there’s something not quite right about the line that calls msiexec.exe. That could be one of a number of things, but the first things I’d look at would be whether you have an unmatched quote mark, or a relative path where it should be absolute perhaps.

  2. Pingback: Automating uninstalls of Sitecore | Jeremy Davis
  3. Pingback: Unattended installs again: Understanding some more Sitecore MSI parameters | Jeremy Davis
  4. Pingback: Revisiting install scripting for newer versions of Sitecore | Jeremy Davis
  5. Pingback: Development environments with PowerShell DSC – Part 5 | Jeremy Davis

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s