Loading
Run wmi vbscript with a custom action
Hi everybody,

 

I was wondering how to use custom actions to run a vbscript.

 

when i run a vbscript using WSH in a custom action , i have the error 1720

 

Problem: When i created my custom action, i choose the type "Run VBScript code"then the location"Stored in the Binary table" and in the sour ce path i put my vbscript. But i don't know what to put in the Target.

 

To help you, this is my vbscript :

 

' This code joins a computer to a domain.

 

' The JoinDomainOrWorkGroup( ) method was introducted in Windows XP

 

' so this code works only against Windows XP and Windows Server 2003.

 

' ------ SCRIPT CONFIGURATION ------

 

strComputer = "." ' e.g. joe-xp

 

strDomain = "test.local" ' e.g. rallencorp.com

 

strDomainUser = "test\testuser" ' e.g. administrator@rallencorp.com

 

strDomainPasswd = "test1234"

 

strLocalUser = "" ' e.g. administrator

 

strLocalPasswd = ""

 

' ------ END CONFIGURATION ---------

 

'

 

' Constants

 

'

 

Const JOIN_DOMAIN = 1

 

Const ACCT_CREATE = 2

 

Const ACCT_DELETE = 4

 

Const WIN9X_UPGRADE = 16

 

Const DOMAIN_JOIN_IF_JOINED = 32

 

Const JOIN_UNSECURE = 64

 

Const MACHINE_PASSWORD_PASSED = 128

 

Const DEFERRED_SPN_SET = 256

 

Const INSTALL_INVOCATION = 262144

 

'

 

' Connect to Computer

 

'

 

Set WshNetwork = WScript.CreateObject("WScript.Network")

 

strComputer = WshNetwork.ComputerName

 

 

set objWMILocator = CreateObject("WbemScripting.SWbemLocator")

 

objWMILocator.Security_.AuthenticationLevel = 6

 

set objWMIComputer = objWMILocator.ConnectServer(strComputer, _

 

"root\cimv2")

 

set objWMIComputerSystem = objWMIComputer.Get( _

 

"Win32_ComputerSystem.Name='" & _

 

strComputer & "'")

 

'

 

' Join Computer

 

'

 

rc = objWMIComputerSystem.JoinDomainOrWorkGroup(strDomain, _

 

strDomainPasswd, _

 

strDomainUser, _

 

vbNullString, _

 

JOIN_DOMAIN + ACCT_CREATE)

 

if rc <> 0 then

 

WScript.Echo "Join failed with error: " & rc

 

else

 

WScript.Echo "Successfully joined " & strComputer & " to " & strDomain

 

end if

 

Thanks

 

Franck:confused:

  • change

     

    Set WshNetwork = WScript.CreateObject("WScript.Network")

     

    to

     

    Set WshNetwork = CreateObject("WScript.Network")

     

     

    The session object is bound to an activescript running in MSI, not WScript or CScript as is the case when running from cscript.exe or wscript.exe.

     

    Also note that VB/JScript CA's are 'evil' ( google, you'll see ). I'd reccomend porting this functionality over to InstallScript.
    Expand Post

Related  Product Forums


                     â†’ Flexera One



                      â†’ Snow Atlas



                      â†’ FlexNet Manager



                      â†’ Snow License Manager



                       â†’ App Broker


       Need help finding an answer?


        Ask a Question →


Loading
Run wmi vbscript with a custom action