VBScript to set MSI Property
Hi All,
I am a newbie to VBScript so hopefully someone can help. I am trying to write a VBScript to dynamically set a Property in an MSI. The value of the property is a registry key value that differs from PC to PC. The script is being called from a Custom Action within the MSI. i am using Wise Package Studio 5 to create this MSI.
Here is my script so far:
Dim WShell, DISKID
Set WShell = WScript.CreateObject("WScript.Shell")
DISKID = WShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\0")
Session.Property(DISKID) = DISKID
I've scrolled the internet and found very little that resembles what i'm trying to do.
Help please.
Scott
I am a newbie to VBScript so hopefully someone can help. I am trying to write a VBScript to dynamically set a Property in an MSI. The value of the property is a registry key value that differs from PC to PC. The script is being called from a Custom Action within the MSI. i am using Wise Package Studio 5 to create this MSI.
Here is my script so far:
Dim WShell, DISKID
Set WShell = WScript.CreateObject("WScript.Shell")
DISKID = WShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\0")
Session.Property(DISKID) = DISKID
I've scrolled the internet and found very little that resembles what i'm trying to do.
Help please.
Scott
0 Comments
[ + ] Show comments
Answers (11)
Please log in to answer
Posted by:
brenthunter2005
19 years ago
Posted by:
Scotty
19 years ago
Sorry, forgot to include the error message: When running this script as a Custom Action "Call VBScript from Installation", i generate an msi error log that says:
Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action Action1 script error -2146827864, Microsoft VBScript runtime error: Object required: 'WScript' Line 3, Column 1,
However, when i run the script by itself i get:
Line: 5
Char: 1
Error: Object required: "Session"
Code: 800A0148
Source: Microsoft VBScript runtime error
Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action Action1 script error -2146827864, Microsoft VBScript runtime error: Object required: 'WScript' Line 3, Column 1,
However, when i run the script by itself i get:
Line: 5
Char: 1
Error: Object required: "Session"
Code: 800A0148
Source: Microsoft VBScript runtime error
Posted by:
brenthunter2005
19 years ago
Posted by:
Scotty
19 years ago
Thanks for your help MR B Hunter, it worked!!! I also had to amend my Session.Property line slightly to get it to work so my final code looked like this:
Dim WShell, DISKID
Set WShell = CreateObject("WScript.Shell")
DISKID = WShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\0")
Session.Property("DISKID") = DISKID
Thanks again, really appreciate it!!. Hope this helps others too.
I'm sure there's a "Points" system operating here so i'm more than happy to award some to Mr B Hunter but dont know how. Please advise.
Scott
Dim WShell, DISKID
Set WShell = CreateObject("WScript.Shell")
DISKID = WShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\0")
Session.Property("DISKID") = DISKID
Thanks again, really appreciate it!!. Hope this helps others too.
I'm sure there's a "Points" system operating here so i'm more than happy to award some to Mr B Hunter but dont know how. Please advise.
Scott
Posted by:
brenthunter2005
19 years ago
Posted by:
shanushaan
15 years ago
Hi brenthunter,
I am using the same thing as you have explained here, still while debugging through the Windows debugger the MSI goes for a toss after I set a property.
What are the condition in the installation that I have to look for, before I can set a property in the MSI using VBScript
I am trying to do it through embeded VB script code
I am using the same thing as you have explained here, still while debugging through the Windows debugger the MSI goes for a toss after I set a property.
What are the condition in the installation that I have to look for, before I can set a property in the MSI using VBScript
I am trying to do it through embeded VB script code
Posted by:
anonymous_9363
15 years ago
- I presume you mean the Wise Package Studio debugger?
- No conditions are required to set a property via script.
- Which property are you trying to set? Post the code here (remembering to use the CODE tag, accessible bu clicking the button marked '<%' in the 'Reply to Message' window.)
- In which sequence does the CA containing the script execute and where (e.g. before or after InstallFinalize)?
- No conditions are required to set a property via script.
- Which property are you trying to set? Post the code here (remembering to use the CODE tag, accessible bu clicking the button marked '<%' in the 'Reply to Message' window.)
- In which sequence does the CA containing the script execute and where (e.g. before or after InstallFinalize)?
Posted by:
shanushaan
15 years ago
function readFromRegistry (strRegistryKey )
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( strRegistryKey )
If err.number <> 0 Then
readFromRegistry= "Error"
else
readFromRegistry=value
end if
set WSHShell = nothing
end function
dbNavicligudVer = 7.28
str = readfromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\emc\Navisphere CLI\CLIVersion")
str2 = Left(str,1)
str3 = Mid(str,3,2)
str4 = str2+"."+str3
db = cdbl(str4)
If db < dbNavicligudVer Then
ans = MsgBox("We will upgrade Navicli", 65, "Error")
Session.Property("NAVITEST")=ans
Else
wscript.echo "The Current Version of NAVICLI is good"
end if
I want to set NAVITEST property here and after that I can use NAVITEST property to launch navicli upgrade
Posted by:
anonymous_9363
15 years ago
Posted by:
shanushaan
15 years ago
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.