Sofia
2007-03-14 11:15:20 UTC
Hi! :)
Is it possible to start a process on a remote machine using a local account
on that machine?
If so, how do I do it? What's wrong with my test script?
My test below returns "SWbemLocator: Access is denied." on the
ConnectServer() row.
I have always used my domain admin account to impersonate previouslly so
I've never needed to do this but now a licence is tied to the local
account...
Thanks a million! :)
/Sofia
---------------------------------------------------------------
VBScript:
Option Explicit
'WMI constants
Const wbemImpersonationLevelImpersonate = 3
Const wbemAuthenticationLevelPktPrivacy = 6
'The computer to run on
Dim strComputer : strComputer = "computername" 'my 2003 SP1 server
'The program/command to run
Dim strProgram : strProgram = "notepad.exe"
'Use this account and password
Dim strUserName
strUserName = "username" 'local user account (member of local administrators
group)
'strUserName = Chr(34)+"computername\account"+Chr(34) 'also tested
Dim strPassword : strPassword = "Visma06"
'Connect to WMI (root\cimv2) on Remote machine using specified credentials
Dim objLocator, objWMIService
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2",
strUserName, strPassword)
objWMIService.Security_.ImpersonationLevel =
wbemImpersonationLevelImpersonate
objWMIService.Security_.AuthenticationLevel =
wbemAuthenticationLevelPktPrivacy
'Create the process
Dim errReturn, intProcessID
errReturn = objWMIService.Create(strProgram, null, null, intProcessID)
'Check for errors
If errReturn = 0 Then
Wscript.Echo strProgram+" was started with a process ID of
"+CStr(intProcessID)+"."
Else
Wscript.Echo strProgram+" could not be started due to error
"+CStr(errReturn)+"."
End If
Is it possible to start a process on a remote machine using a local account
on that machine?
If so, how do I do it? What's wrong with my test script?
My test below returns "SWbemLocator: Access is denied." on the
ConnectServer() row.
I have always used my domain admin account to impersonate previouslly so
I've never needed to do this but now a licence is tied to the local
account...
Thanks a million! :)
/Sofia
---------------------------------------------------------------
VBScript:
Option Explicit
'WMI constants
Const wbemImpersonationLevelImpersonate = 3
Const wbemAuthenticationLevelPktPrivacy = 6
'The computer to run on
Dim strComputer : strComputer = "computername" 'my 2003 SP1 server
'The program/command to run
Dim strProgram : strProgram = "notepad.exe"
'Use this account and password
Dim strUserName
strUserName = "username" 'local user account (member of local administrators
group)
'strUserName = Chr(34)+"computername\account"+Chr(34) 'also tested
Dim strPassword : strPassword = "Visma06"
'Connect to WMI (root\cimv2) on Remote machine using specified credentials
Dim objLocator, objWMIService
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2",
strUserName, strPassword)
objWMIService.Security_.ImpersonationLevel =
wbemImpersonationLevelImpersonate
objWMIService.Security_.AuthenticationLevel =
wbemAuthenticationLevelPktPrivacy
'Create the process
Dim errReturn, intProcessID
errReturn = objWMIService.Create(strProgram, null, null, intProcessID)
'Check for errors
If errReturn = 0 Then
Wscript.Echo strProgram+" was started with a process ID of
"+CStr(intProcessID)+"."
Else
Wscript.Echo strProgram+" could not be started due to error
"+CStr(errReturn)+"."
End If