Launch/abort msi using a condition
Hi all,
I have a .exe install which I will install silently using the manufacturer -silent switch. Then there is a msi drivers package which must be installed on some machines but not all. Which is the best way to go here you think? This will be installed using SCCM.
I tried to use a custom action and use WMI from a vbscript to check if a certain computermodel were used, if so, the install would exit. Here is what I did:
1. Right click on custom actions. Selected new vbscript -> stored in binary table.
2. Named it "test"
3. Browsed to the vbsript in the "VBScript Filename" field.
Here is the VBScript:
Function ExitSetupFromVBS()
Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
IF srtModel= "HP EliteBook 6930p" Then
IDABORT = 3
ELSE
IDABORT = 0
End If
ExitSetupFromVBS = IDABORT
End Function
4. Under Script Function I entered: "ExitSetupFromVBS"
5. I inserted the CA under "Install UI Sequence" after "SetupInitialization".
This way my plan is to skip the installation if its run on a HP EliteBook 6930p.
When I install the msi from a command line I get "Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run".
Any ideas what I´m doing wrong?
I have a .exe install which I will install silently using the manufacturer -silent switch. Then there is a msi drivers package which must be installed on some machines but not all. Which is the best way to go here you think? This will be installed using SCCM.
I tried to use a custom action and use WMI from a vbscript to check if a certain computermodel were used, if so, the install would exit. Here is what I did:
1. Right click on custom actions. Selected new vbscript -> stored in binary table.
2. Named it "test"
3. Browsed to the vbsript in the "VBScript Filename" field.
Here is the VBScript:
Function ExitSetupFromVBS()
Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
IF srtModel= "HP EliteBook 6930p" Then
IDABORT = 3
ELSE
IDABORT = 0
End If
ExitSetupFromVBS = IDABORT
End Function
4. Under Script Function I entered: "ExitSetupFromVBS"
5. I inserted the CA under "Install UI Sequence" after "SetupInitialization".
This way my plan is to skip the installation if its run on a HP EliteBook 6930p.
When I install the msi from a command line I get "Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run".
Any ideas what I´m doing wrong?
0 Comments
[ + ] Show comments
Answers (20)
Please log in to answer
Posted by:
MSIPackager
14 years ago
Posted by:
anonymous_9363
14 years ago
You're getting a 1720 error because you're using 'WScript' directives (e.g. WScript.Echo) which are only valid when "talking" to Windows Scripting Host. The WI engine has its own (let's call it) interpreter which it uses when running embedded script and this will throw an error at anything beginning with such. Note, however, that this does NOT apply to the creation and use of WScript objects (e.g. WScript.Shell or WScript.Network). Note also that you can use these directives running non-embedded scripts.
By default these days, I include a test in my scripts for detecting whether it's running in a CA and setting an appropriately-named Boolean variable. The script can then be tested outside of a CA and, when ready, placed into the CA with no alteration required.
By default these days, I include a test in my scripts for detecting whether it's running in a CA and setting an appropriately-named Boolean variable. The script can then be tested outside of a CA and, when ready, placed into the CA with no alteration required.
Posted by:
stf40
14 years ago
Posted by:
Agathorn
14 years ago
Posted by:
MSIPackager
14 years ago
Posted by:
Agathorn
14 years ago
Yes I guess that´s a good option as well. But we are migrating from Novell to MS and SCCM so that environment isn´t up and running just yet.
I can place the script in Novell Console One instead of in a CA but then I have to do the filtering again in SCCM. So I just figured if I make a CA instead I don´t have to think about it again.
I can place the script in Novell Console One instead of in a CA but then I have to do the filtering again in SCCM. So I just figured if I make a CA instead I don´t have to think about it again.
Posted by:
Agathorn
14 years ago
I stumbled upon this page that describes how to use vbscript to set a value to a property which you then can use. But I´m not following how the value is being returned from the script into the property which I later on can use.
http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/
He is talking about "session variable" which I dont know what is. Help would be appreciated.
http://www.installationdeveloper.com/618/sql-server-version-detection-in-installshield/
He is talking about "session variable" which I dont know what is. Help would be appreciated.
Posted by:
MSIPackager
14 years ago
OK, well you need to get to grips with using session.property in your vbscript to pass the result back to a Windows Installer property. You then need to sequence the CA before the LaunchConditions action so that you can use the property value as a launch condition - and abort the install if the model you've specified is found.
Here are a few links to the relevant MSDN pages, but you'll find loads of examples on this site and the www
http://msdn.microsoft.com/en-us/library/aa371681(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa369751(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa369752(VS.85).aspx
Hope this helps...
Regards,
Rob.
Here are a few links to the relevant MSDN pages, but you'll find loads of examples on this site and the www
http://msdn.microsoft.com/en-us/library/aa371681(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa369751(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa369752(VS.85).aspx
Hope this helps...
Regards,
Rob.
Posted by:
anonymous_9363
14 years ago
I´m pretty new to Install Shield and very new to Custom Actions and conditions etc.I agree that a LaunchCondition is the way to go. Note, however, when building CAs, you need to take account of different install scenarios. If a CA is set to run only in the UI sequence, it follows that it will not be run if the UI sequence isn't executed, i.e. during a silent install.
Posted by:
Agathorn
14 years ago
Thanks VBScab. I´ll put the CA in another place instead when finalising the package.
However I´m struggling with How I should create a CA that saves a value into a property from a vbscript. I´ve googled and searched the forums but I´m yet to find the solution.
I created a property in the property manager called "IS6930p".
Then I changed the vbscript to this:
Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
wscript.echo strModel
wscript.echo strSerial
IF srtModel= "HP EliteBook 6930p" Then
Session.Property("IS6930p")="YES"
ELSE
Session.Property("IS6930p")="NO"
END IF
Also changed the location of the CA to "Install Exec Sequence" and after "FindRElatedProducts" but the installer throws a error message "Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run."
However I´m struggling with How I should create a CA that saves a value into a property from a vbscript. I´ve googled and searched the forums but I´m yet to find the solution.
I created a property in the property manager called "IS6930p".
Then I changed the vbscript to this:
Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
wscript.echo strModel
wscript.echo strSerial
IF srtModel= "HP EliteBook 6930p" Then
Session.Property("IS6930p")="YES"
ELSE
Session.Property("IS6930p")="NO"
END IF
Also changed the location of the CA to "Install Exec Sequence" and after "FindRElatedProducts" but the installer throws a error message "Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run."
Posted by:
Agathorn
14 years ago
Ok thanks, I commented those lines. Keep getting the same error though :/
EDIT: My bad, forgot to remove the function call in the CA. Installer runs now, so the script is working so far.
EDIT2: Well the installer runs but how do I check of "YES" or "NO" is beeing written to the property? I have logged the installation but I can only see that the property is set to "NO" initially by myself in Install Shield. And that the CA with the script returns "0" after it´s done.
EDIT3: If I skip the check of the property has been given a value or not. Which action should I write a condition for? "IS6930P=NO"
EDIT: My bad, forgot to remove the function call in the CA. Installer runs now, so the script is working so far.
EDIT2: Well the installer runs but how do I check of "YES" or "NO" is beeing written to the property? I have logged the installation but I can only see that the property is set to "NO" initially by myself in Install Shield. And that the CA with the script returns "0" after it´s done.
EDIT3: If I skip the check of the property has been given a value or not. Which action should I write a condition for? "IS6930P=NO"
Posted by:
MSIPackager
14 years ago
Posted by:
Agathorn
14 years ago
Yes I use \L*V for logging.
This is a copy paste from the log
Property(S): EXECUTEACTION = INSTALL
Property(S): ROOTDRIVE = C:\
Property(S): PackagecodeChanging = 1
Property(S): ProductState = -1
Property(S): TRANSFORMS = C:\HP USB keyboard smartcard drivers\HP USB keyboard smartcard drivers.Mst
Property(S): PackageCode = {FC6581AC-9DD8-48AD-8D52-66CBEE40022B}
Property(S): IS6930P = NO
Property(S): UILevel = 5
Property(S): Preselected = 1
Property(S): CostingComplete = 1
Property(S): OutOfDiskSpace = 0
Property(C): VersionDatabase = 200
Property(C): PackagecodeChanging = 1
Property(C): ProductState = -1
Property(C): CURRENTDIRECTORY = C:\HP USB keyboard smartcard drivers
Property(C): TRANSFORMS = C:\HP USB keyboard smartcard drivers\HP USB keyboard smartcard drivers.Mst
Property(C): PackageCode = {FC6581AC-9DD8-48AD-8D52-66CBEE40022B}
Property(C): IS6930P = NO
Property(C): CostingComplete = 1
Property(C): SourcedirProduct = {E24A2D94-3215-4E81-A8BA-17BC0E577597}
Property(C): OutOfDiskSpace = 0
Property(C): OutOfNoRbDiskSpace = 0
Property(C): PrimaryVolumeSpaceAvailable = 0
Property(C): PrimaryVolumeSpaceRequired = 0
These are the two places the property are mentioned. Apart from calling the CA which has that word in it´s name as well.
I tried placing the CA all over the install sequence to rule out that kind of problem, to no effect.
This is a copy paste from the log
Property(S): EXECUTEACTION = INSTALL
Property(S): ROOTDRIVE = C:\
Property(S): PackagecodeChanging = 1
Property(S): ProductState = -1
Property(S): TRANSFORMS = C:\HP USB keyboard smartcard drivers\HP USB keyboard smartcard drivers.Mst
Property(S): PackageCode = {FC6581AC-9DD8-48AD-8D52-66CBEE40022B}
Property(S): IS6930P = NO
Property(S): UILevel = 5
Property(S): Preselected = 1
Property(S): CostingComplete = 1
Property(S): OutOfDiskSpace = 0
Property(C): VersionDatabase = 200
Property(C): PackagecodeChanging = 1
Property(C): ProductState = -1
Property(C): CURRENTDIRECTORY = C:\HP USB keyboard smartcard drivers
Property(C): TRANSFORMS = C:\HP USB keyboard smartcard drivers\HP USB keyboard smartcard drivers.Mst
Property(C): PackageCode = {FC6581AC-9DD8-48AD-8D52-66CBEE40022B}
Property(C): IS6930P = NO
Property(C): CostingComplete = 1
Property(C): SourcedirProduct = {E24A2D94-3215-4E81-A8BA-17BC0E577597}
Property(C): OutOfDiskSpace = 0
Property(C): OutOfNoRbDiskSpace = 0
Property(C): PrimaryVolumeSpaceAvailable = 0
Property(C): PrimaryVolumeSpaceRequired = 0
These are the two places the property are mentioned. Apart from calling the CA which has that word in it´s name as well.
I tried placing the CA all over the install sequence to rule out that kind of problem, to no effect.
Posted by:
Agathorn
14 years ago
Posted by:
Agathorn
14 years ago
Posted by:
anonymous_9363
14 years ago
Have you tested the actual value returned in strModel? Your test is for "HP EliteBook 6930p" but it might return "HP EliteBook 6930P", in which case the strings don't match.
When comparing strings, I find it best to switch both sides to upper-case or lower-case first:
When comparing strings, I find it best to switch both sides to upper-case or lower-case first:
If UCase(strModel) = "HP ELITEBOOK 6930P" Then
Posted by:
MSIPackager
14 years ago
Works here:
MSI (s) (48!EC) [13:18:08:164]: PROPERTY CHANGE: Modifying IS6930P property. Its current value is 'DAVE'. Its new value: 'YES'.
I'm calling the custom action right before Launch Conditions (Execute Immediate), via embedded VBScript CA:
MSI (s) (48!EC) [13:18:08:164]: PROPERTY CHANGE: Modifying IS6930P property. Its current value is 'DAVE'. Its new value: 'YES'.
I'm calling the custom action right before Launch Conditions (Execute Immediate), via embedded VBScript CA:
Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
'wscript.echo strModel
'wscript.echo strSerial
IF strModel= "HP Compaq dc7900 Small Form Factor" Then
Session.Property("IS6930P")="YES"
msgbox "Yes"
ELSE
Session.Property("IS6930P")="NO"
msgbox "No"
END IF
Posted by:
Agathorn
14 years ago
Posted by:
ncmonag
14 years ago
I wrote a tool that does something similar using AutoIt and the devcon tool to verify a specific piece of hardware and then run an exe/msi, update the hardware using devcon, or disable the hardware using devcon. I wrote it initially to update/disable hardware on our BootCamp Macs but it soon evolved.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.