Share via


Automaticly run Program\Script After and MSI Installation

Question

Monday, September 1, 2014 5:44 PM

Hi All,

Today I started looking into the use of Application Model in SCCM 2012.

It was easy to create an application by using the import MSI function, which automatically created the application, deployment type and detection rule. But I'm struggling with how to run a script afterwards, when the MSI installation was successful.

I've looked into creating 2nd deployment type making the first deployment type as it's dependency, but it's mandatory that I also need to make an detection rule. And this is where I'm stuck ass the detection rule I want to have the same as for the first deployment type which will make it impossible to run because the condition will be evaluated ass already installed.

Is there a way to avoid the detection rule? If not is if possible trigger something after the first deployment type based on the errorlevel after the MSI installation.

My goal is to write a regkey  somewhere in HKLM\Software\company name> after an successful installation of an application. This location we've included in our hardware inventory for reporting purposes.

Any suggestions to achieve this goal are welcome .

Regards,

Daniel

All replies (7)

Monday, September 1, 2014 9:05 PM ✅Answered

Hi,

There are other options one would be to create and application of the script and deploy it and set the application as a dependency.

You could inlcude the skript in the MSI package and have the MSI package deploy it or use an activesetup.

Or as Jason also writes use a script that install the application and run your script, I would use PSappdeploymentoolkit which has a lot of features like install a patch, run a script e.t.c and take the time to creat an application of the PSappdeployment toolkit, which will use the same command line for all applications so it is still somewhat easy,..

https://psappdeploytoolkit.codeplex.com/

Regards,
Jörgen

-- My System Center blog ccmexec.com -- Twitter @ccmexec


Monday, September 1, 2014 9:17 PM ✅Answered

Or you could use Orca to create a .mst file that contains the registry keys and use that with your .msi package.


Monday, September 1, 2014 7:59 PM

Use a script that first executes the MSI and then performs the reg edit, place this script in the same source location as your MSI, and then call the script instead of the MSI in your deployment type.

Jason | http://blog.configmgrftw.com | @jasonsandys


Monday, September 1, 2014 8:39 PM

I also thought about that. But when looking in automating the creation of Applications with deployment types with the Powershell Module. It's easier to import the MSI files with Powershell which create most of the configuration in one go. The creation of a manual script based application type needs more scripting to accomplish this.

If there is no other way I agree and this will be the way to go.

Regards,

Daniel


Tuesday, September 9, 2014 7:59 AM

I've resolved it with using the AddDploymentTypebyMISInstallerAuto function from the Add-CMDeployment command and provided an InstallationProgram parameter to override the default InstallationProgram.

The comman-line looks like

Add-CMDeploymentType -ApplicationName <Name> -AutoIdentifyFromInstallationFile -ForceForUnknownPublisher $True `

-InstallationFileLocation <MSI File> -MsiInstaller -DeploymentTypeName Test1 –InstallationBehaviorType InstallForSystem -InstallationProgram < Custom Script>

In this way I have the detection based on the MSI GUID and the ability to use a wrapper script.


Tuesday, September 9, 2014 3:24 PM

You can use an MSI detection with a non-MSI based deployment type so the above doesn't really do anything for you. In fact, using an MSI deployment type for a script will cause you issues because ConfigMgr will append parameters to the command-line and assume functionality that does not apply to non-MSI based command-lines.

Jason | http://blog.configmgrftw.com | @jasonsandys


Friday, September 12, 2014 2:19 PM | 1 vote

The easiest way to do will be the following:

1. Create a new Application for just the MSI, with the default detection MSI detection rule.

2. Create another Deployment Type which will be "Script Installer" for the script you want to run after MSI installation.

3. Make first deployment type as its dependency.

4. In the detection rules for "Script Installer" deployment type you should add two detection rules using the AND clause. One will be your the MSI detection for the dependency MSI and second will be the registry you wish to write.

5 Now when you deploy the second deployment type to clients, both will be checked and even if one is missing the installation will begin. (For MSI deployment type only adding default msi detection is sufficient)

-RG

If this thread answers your question please click "Mark as Answer"