Tuesday 25 September 2012

Creating Unattended install for HP fortify:

 

So I was recently tasked with creating a silent install for HP Fortify 3.40 to 3.50.

The initial plan was to create a response transform using the MSI extracted from the EXE package using Installshield Editor. Then create a batch file to first import the certificate that was created for the group of users in our domain who were allowed this software.

But that did not work out as I was unable to create a response transform using the fortify MSI. Whenever I tried I kept getting this error message.

"An error occurred while generating a Response Transform. Would you like to open a blank transform instead of a Response Transform?"

SnipImage

After some googling I figured the best way to get past this was adding the ISSETUP=1 property using the property manager installshield editor and save the MSI and then try. As it happens it didn’t work out too well, I was able to get past the error but none of the binaries actually worked after install.

I tried a different tack and was succesful by creating an answer file for the setup itself. I used

SnipImage

which recorded a setup.iss file in the location specified.

The setup.iss file could then be edited in notepad to specify the location of the license

[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-DlgOrder]
Dlg0={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdWelcome-0
Count=10
Dlg1={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdLicense2Rtf-0
Dlg2={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SelectDir-0
Dlg3={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdAskDestPath-0
Dlg4={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdComponentTree-0
Dlg5={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdStartCopy-0
Dlg6={945899E4-57F5-47D2-B66A-17D9AD5146CE}-AskOptions-0
Dlg7={945899E4-57F5-47D2-B66A-17D9AD5146CE}-ServerSettings-0
Dlg8={945899E4-57F5-47D2-B66A-17D9AD5146CE}-AskOptions-1
Dlg9={945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdFinish-0
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdWelcome-0]
Result=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdLicense2Rtf-0]
Result=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SelectDir-0]
Result=1
szDir=C:\Users\tausifkhan\Desktop\installer

[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdAskDestPath-0]
szDir=C:\Program Files\Fortify Software\HP Fortify v3.40\
Result=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdComponentTree-0]
szDir=C:\Program Files\Fortify Software\HP Fortify v3.40\
SCA-type=string
SCA-count=1
SCA-0=SCA\SCA_FILES
AWB-type=string
AWB-count=4
AWB-0=AWB\IDE
AWB-1=AWB\ScanWizard
AWB-2=AWB\AWB_FPR
AWB-3=AWB\ProcessDesign
Component-type=string
Component-count=2
Component-0=SCA
Component-1=AWB
Result=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdStartCopy-0]
Result=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-AskOptions-0]
Result=1
Sel-0=0
Sel-1=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-ServerSettings-0]
updateServer=https://update.fortify.com
updateProxyServer=' '
updateProxyPort=' '
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-AskOptions-1]
Result=1
Sel-0=0
Sel-1=1
[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0

 

The highlighted location was the part I needed to modify to pull the license off our fileshare. So instead of:

[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SelectDir-0]
Result=1
szDir=C:\Users\tausifkhan\Desktop\installer

I would modify it to :

[{945899E4-57F5-47D2-B66A-17D9AD5146CE}-SelectDir-0]
Result=1
szDir=\\myfileshare\licenselocation

Which very conveniently did not involve keeping the license on the same location as the binaries.

Now all I needed to figure out was a way to install the certificate and then run the setup unattended using the answer file.

Installing the certificate involved the use of certutil:

certutil -addstore -user -f ”My” %locationofcert%\certifictate.cer

next I had to run the install itself and keep the window open while it installed. So:

@echo off
setLocal
:: local variable %percent% is reserved!
@echo off

echo Importing digital licence...

certutil -addstore -user -f ”My” %locationofcert%\certifictate.cer

echo Installing HP fortify X64
start /w C:\Users\TausifKhan\Desktop\installer\x64\HP_Fortify_3.40_SCA_and_Apps_Windows_x64.exe /s /f1C:\Users\TausifKhan\Desktop\installer\x64\setup.iss
call :DisplayProgressBar %sProc% 3

:End of Batch


goto:EOF --------------------
:DisplayProgressBar SUBROUTINE
If not defined percent (
   setlocal
   echo.&echo/    * DO NOT CLOSE THIS WINDOW *&echo.
   Set "wait=ping -n 200000 127.0.0.1 > NUL"
   Set "monitoring=%1"
   Set /a n = %2
   set /a percent = 0
   <nul (Set /P j=Installing)
) Else ( <nul (Set /P j=.) )
>nul 2>&1 (
   title %percent% %%  Completed
   If %n% NEQ 1 (
      For /f %%# in (
        'tasklist.exe ^| find /i /c "%monitoring%"'
      ) Do if NOT %%# GTR 0 Set /a n = 1
   )
)
>nul (%wait% %n%) & set /a percent = percent + 1
If %percent% LEQ 100 (
   call:DisplayProgressBar
) Else (
title Done
<nul (Set /P j=) & echo/100%% Completed
>nul (%wait% 2)
EndLocal
)
goto:EOF --------------------

 

Which seemed to do the trick, the only problem was that I also needed to specify the location of setup.iss itself explicitly on the batch file. Apart from that this worked beautifully.

Detect autopilot session

  Ensuring that some apps only install during autopilot is not easily accomplished, you can use the below powershell script as a requiremen...