0

I create a Win32Process (cmd.exe) on a remote machine using WMI.

C:\Users\ayush_m>wmic /node:10.0.0.0 /user:ayush_m /password:pwd PROCESS CALL Create "cmd.exe"
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ProcessId = 10088;
        ReturnValue = 0;
};

The ProcessID returned by WMI (10088) is the PID of the cmd.exe process started at the remote machine. Now i would like to run some other commands such as mkdir or copy or run an exe file using above PID .i.e use the PID that i have above (10088) and run many more commands on that machine.

I basically do not want to create a new Win32Process everytime i run a command. Please suggest any ideas or observations.

Thanks in advance for help.

1
  • 3
    You cannot use the same cmd.exe instance to run a new command, instead you can execute a batch file (.bat) to execute multiple tasks.
    – RRUZ
    Jul 9, 2013 at 18:49

1 Answer 1

0

From what I understand you could be looking for some remote shell - did you try using PsExec? Wmic just spawns a process but doesn't grant any kind of control over it. As RRUZ suggests, create a BAT/VBS file to execute what you need, or if your environment supports PowerShell, have PowerShell do the stuff.

To sum up:

  1. To have an interactive console - use PsExec
  2. To execute a set of tasks (ex. create C:\MyDirectory and put some logs there) - create a BAT/VBS file and call it using wmic just as you did with cmd.exe
  3. PowerShell could certainly be helpful here if you need to automate things. It was created with automation in mind, so take advantage of it :-)

Best regards, AlexP

(I'm not sure if I'm not grave-digging at the moment, the question is quite old what I noticed just now, but still didn't have an answer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.