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
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
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
Answered 05/19/2005 by: Scotty
Senior Yellow Belt

Please log in to comment
2
[8D]

Change the following line:

Set WShell = WScript.CreateObject("WScript.Shell")

to:

Set WShell = CreateObject("WScript.Shell")


You can't use the WScript object model like this within a MSI custom action.
Answered 05/20/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
Also, if you run the script by itself you will get an error relating to the object "Session" as that ONLY exists within a MSI custom action.
Answered 05/20/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
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
Answered 05/22/2005 by: Scotty
Senior Yellow Belt

Please log in to comment
0
[8D] Nice one Scotty. Glad I could help.

The points system is explained in the main forum, and you can click on the "Rate Posts" to award points.


[:D] Cheers! [:D]
Answered 05/23/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
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
Answered 08/17/2009 by: shanushaan
Yellow Belt

Please log in to comment
0
- 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)?
Answered 08/17/2009 by: VBScab
Red Belt

Please log in to comment
0

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
Answered 08/17/2009 by: shanushaan
Yellow Belt

Please log in to comment
0
Ummm....Why not simply use the Upgrade table? That is its exact purpose...
Answered 08/17/2009 by: VBScab
Red Belt

Please log in to comment
0
Our product installer is separate. That installer looks for the navicli version and based on that tries to upgrade Navicli.
Its something like from an MSI i have to upgrade a different licensed tool.
Answered 08/17/2009 by: shanushaan
Yellow Belt

Please log in to comment
0
I have no clue what you're trying to tell us here.
Answered 08/17/2009 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity