Jump to content

Recommended Posts

Guest Krishna Chaitanya
Posted

Hi,

 

I have to use a combination of alternative username/password

credentials and remote process creation and fetching its output on

termination. So I can't use the moniker style GetObject as it doesn't

support alternative username.

 

Am using the following code, but it creates the process, gives me the

PID but when I RDC to that remote machine, I don't see that PID in the

task manager. What could be wrong? Please help me. The following code

is taken largely from the MSDN link http://msdn.microsoft.com/en-us/library/aa384833(VS.85).aspx

 

--------------*-------------*------------------

 

Set locator = CreateObject("WbemScripting.SWbemLocator")

Set service = locator.ConnectServer("192.168.1.34","root

\cimv2","Administrator","password")

service.Security_.ImpersonationLevel = 3

 

Set process = service.Get("Win32_Process")

 

Set inparams = process.Methods_("Create").InParameters.SpawnInstance_

inparams.Properties_.Item("CommandLine") = "Notepad.exe"

 

Set outparams = process.ExecMethod_("Create",inparams)

 

If Error = 0 Then

WScript.Echo "Process created with PID of " & outparams.ProcessId

End If

  • Replies 0
  • Created
  • Last Reply

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...