Embeded VBscript error

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

Answers (3)

Posted by: anonymous_9363 13 years ago
Red Belt
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.
Posted by: captain_planet 13 years ago
Black Belt
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....
Posted by: anonymous_9363 13 years ago
Red Belt
LOL...I had thought of seeking that post out but decided not to bother. Thanks, Cap'n!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ