简体   繁体   中英

vbscript permission denied: getobject

I'm trying to execute a batch file which is located in a server from a vbscript in my local system.

Below code throws permission denied while accessing GETOBJECT

strDomain = "SBICAD"
strComputer = "10.29.83.22"
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, _
"root\cimv2", _
 "ec12345", _
"sorry@1", _
 "MS_409", _
 "ntlmdomain:" + strDomain)

        objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" & _
                        "\\" & strComputer & _
                        "\root\cimv2:Win32_Process")



result = objWMIService.Create("C:\script\checkremote.bat", Null, Null,process)


Msgbox result 
WScript.Quit

Is there anyway to pass my server login credentials on GetObject?

Note: The user ec12345 has admin rights.

You don't need use the GetObject method because you are already connected with the ConnectServer function. So you only must use the ExecQuery method which will be executed using the same connection.

Set objWMIService = objSWbemServices.ExecQuery("Select * From Win32_Process")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM