I have added a VB script custom action type 3110 to an MSI. It is giving VBSript runtime error: Object required: 'WScript" on the first line that references wscript.

Set StdIn = WScript.StdIn

I read a reference to not using wscript calls in a vbscript here but I don't know what is the alternative?
0 Comments   [ + ] Show 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.


The alternative? Use the object without the WScript directive! WScript refers to the Windows Scripting Host script interpreter. The WI engine uses its own interpreter and knows nothing of WSH. This makes testing of scripts external to WI tricky. What I do is set a Boolean according to whether a well-known MSI property is available:Option Explicit

Dim blnIsCustomAction

blnIsCustomAction = False
blnIsDeferred = False

On Error Resume Next
If IsObject(Session) Then
'// We may have arrived here because error-trapping is off
If Err.Number = 0 Then
blnIsCustomAction = True
End If
End If

'// We test a well-known property and, if it's empty, we MUST be in deferred mode, right?
If Len(Session.Property("UpgradeCode")) = 0 Then
blnIsDeferred = True
End If

On Error Goto 0
Then, later in the code, we can use those Booleans to branch accordingly:

If blnIsCustomAction Then
If blnIsDeferred Then
strTarget = Split(Session.Property("CustomActionData"), ",")(0)
strGroupName = Split(Session.Property("CustomActionData"), ",")(1)
Select Case LCase(strObjectType)
Case "file"
strTarget = Session.Property("FILETOPERMISSION")
Case "folder"
strTarget = Session.Property("FOLDERTOPERMISSION")
Case Else
strTarget = Session.Property("REGKEYTOPERMISSION")
End Select

strGroupName = Session.Property("APPGROUPNAME")
End If
End If
I use it primarily so that my scripts can be run in Execute Immediate of Execute Deferred with minimal editing in between but by testing the Boolean blnIsCustomAction, you can have different sections called depending on whether the script's being run by WSH or by the WI engine.
Answered 07/31/2009 by: VBScab
Red Belt

Please log in to comment
First of all read VBScab's brief description in this thread: http://itninja.com/question/faulttree-100362&mpage=1&key=wscript쓄

What are you trying to achieve anyhow? Microsoft state that StdIn is only available when running your script using CScript.exe as its' host....
Answered 07/31/2009 by: captain_planet
Second Degree Brown Belt

Please log in to comment
LOL...I had thought of seeking that post out but decided not to bother. Thanks, Cap'n!
Answered 07/31/2009 by: VBScab
Red Belt

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