Wednesday, August 19, 2015

Script Update FMAPlus 3

During our FMAPlus 3 deployments, we noticed that the shortcut was not being removed from the desktops in all cases. After examining my old script I figured out what was happening. The script was installing FMAPlus by calling the executable like so .\fma300.exe /S /v"/qn ALLUSERS=2" instead of using Start-Process with a -wait parameter. So on faster machines, the installer would start and the rest of the script would run and exit before the installer was finished.  The installer would then place the shortcut in on the Public\Desktop where it would remain. I have corrected my FMAPlus install script to wait until the installer is finished before continuing.

Tuesday, August 4, 2015

Deploy HEC-RAS 4.1.0 with ConfigMgr

The install of HEC-RAS is very similar to the HEC-SSP install. It is again a simple example of using active setup to take care of a first run prompts that appears for each user. The computer labs where we deploy this software are in part managed by Faronics Deep Freeze, which reverts the computer to its previous state each time it is rebooted. Therefore we do not want the student to have to click through all the first time run prompts every day they use a piece of software. HEC-RAS has a Terms and Conditions for Use prompt that pops up the first time a user runs the program and a prompt to install example projects for HEC-RAS. We are going to use active setup to accept the terms on behalf of the user and remove the example project install prompt.

Active Setup

Using a program like RegShot you can easily find the files and registry entries that are modified between two points in time. Through a process of elimination, I found that the registry entry that handles the TCU popup and example project install prompt is the same key, it is [HKEY_CURRENT_USER\Software\VB and VBA Program Settings\C:\Program Files (x86)\HEC\HEC-RAS\4.1.0\ras\Projects]
"System Statistic"="1073611160" on a 64 bit system.
So I exported this entry into a .reg file.
Here are the contents of the file, you will need to either export your own from Regedit or copy into a file called "HKCU_HEC-RAS.reg"
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\C:\Program Files (x86)\HEC\HEC-RAS\4.1.0\ras\Projects]
"System Statistic"="1073611160"

Install Script

Next create your install script, this one is in PowerShell. I also want to remove previous versions of this software as the installer does not replace them itself. So I will search for and remove all versions before installing.
# Uninstall existing installs
$Installs = get-wmiobject -namespace root\cimv2\sms -query "select * from SMS_InstalledSoftware where ProductName like 'HEC-RAS%'"

foreach ($Install in $Installs)
  $software = $Install.softwarecode
  $UninstallArgs = "/x $software /qn /norestart"
  start-process msiexec.exe -ArgumentList $UninstallArgs -wait
# Install Current Version
$InstallArgs = "/S /v/qn"
Start-Process .\HEC-RAS_410_Setup.exe -ArgumentList $InstallArgs -Wait

# ActiveSetup to remove first run TCU Prompt.
Copy-Item -Path HKCU_HEC-RAS.reg -Destination "${ENV:ProgramFiles(x86)}\HEC\HEC-RAS\4.1.0\HKCU_HEC-RAS.reg" -Force
New-Item -Path Registry::'HKLM\Software\Microsoft\Active Setup\Installed Components\HSU-HEC-RAS-4.1.0' -Force
New-ItemProperty -Path Registry::'HKLM\Software\Microsoft\Active Setup\Installed Components\HSU-HEC-RAS-4.1.0' -Name StubPath -PropertyType String -Value 'CMD /C REG IMPORT "%ProgramFiles(x86)%\HEC\HEC-RAS\4.1.0\HKCU_HEC-RAS.reg"' -Force
New-ItemProperty -Path Registry::'HKLM\Software\Microsoft\Active Setup\Installed Components\HSU-HEC-RAS-4.1.0' -Name Version -PropertyType String -Value '1,0,0,0' -Force

Build Application

Put the reg file, HEC-RAS installer and PowerShell script in your ConfigMgr source.
Create your application, the installation command line I use with PowerShell is
powershell.exe -ExecutionPolicy Unrestricted -File install_HEC-SSP.ps1

Detection Method

The HEC-RAS_410_Setup.exe extracts an msi into %UserProfile%\AppData\Local\Temp\RandomGUID when it is run. You can gather the msi product code from it to use as the detection method. I hand installed in on a computer first to collect the GUID from the msi.

So my detection method in ConfigMgr looks like: