maichinshin
Posts: 1
Joined: Sun Oct 14, 2018 11:52 am

Custom Action VBScript - Property not passed through

Hi there,

I am currently facing an issue when trying to set a public variable through an VBscript in an Custom Action.
Its regarding the Property "MYDOMAIN".
No matter what I am doing, the value is always 0.

Even setting an ";" after (example)

Code: Select all

Session.Property("MYDOMAIN")="1"
does not solve the isse

When the VBScript is executed locally the value can be retrieved (at least in the variable).

Please find my script below:

Code: Select all

'~~~ Query My Domain
Option Explicit

'On Error Resume Next

Dim objWMISvc : Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" )
Dim colItems : Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" )
Dim objSysInfo : Set objSysInfo = CreateObject("ADSystemInfo")
Dim objComp : Set objComp = GetObject("LDAP://" & objSysInfo.ComputerName)
Dim objCompDN : objCompDN = objComp.distinguishedName

Dim objItem
Dim strComputerDomain
Dim Session

For Each objItem in colItems
    strComputerDomain = objItem.Domain
    ' If objItem.PartOfDomain Then
        ' WScript.Echo "Computer Domain: " & strComputerDomain
		' Wscript.Echo "Computername: " & strComputerName
    ' End If
Next


If strComputerDomain = "DOMAIN1.loc" Then
	Session.Property("MYDOMAIN")="1" 


elseif strComputerDomain = "DOMAIN2.loc" Then
	call CheckIRL(objCompDN,"(?:Division-)(8[0-9]\d{1,2}|982)-") 

elseif strComputerDomain = "DOMAIN3.loc" Then
	Session.Property("MYDOMAIN")="3"

Else
    if strComputerDomain = "" then
        Session.Property("MYDOMAIN")="0"
    End if
End if



Sub CheckIRL(strReturnValue, strPattern)
	Dim objRegEx : set objRegex = new RegExp
    objRegex.pattern = strPattern
    objRegex.global = true
	
	If objRegex.Test( strReturnValue ) Then
		Session.Property("MYDOMAIN") = "6"
	Else
		Session.Property("MYDOMAIN") = "7"
	End If
End Sub


Sub CheckSLO(strReturnValue, strPattern)
	Dim objRegEx : set objRegex = new RegExp
    objRegex.pattern = strPattern
    objRegex.global = true
	
	If objRegex.Test( strReturnValue ) Then
		Session.Property("MYDOMAIN") = "4"
	Else
		Session.Property("MYDOMAIN") = "5"
	End If
End Sub
To be honest: I am out of ideas...
A friend inserted the script into an InstallShield project and the Property could be resolved.

Any idea is appreciated :)


Cheers
Thomas
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom Action VBScript - Property not passed through

Hello Thomas and welcome to our forums,

I am not sure why that happens. Could you please send me the .aip (project file) and a verbose log of the installation process by e-mail at support at advancedinstaller dot com so I can further investigate this?

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”