Hi I'm trying to use wmic (the WMI command-line) to start notepad.exe.
I know that I need to type "cscript //nologo CreateProcess.v bs TestPC %windir%\system 32\notepad.exe %temp%" into command prompt, but I'm stuck on what to put in the script file. I have an outline of what to put from a site:
I have filled out the bits I think I know.
Firstly, is this correct? And secondly, what should I be putting where to start notepad.exe?
I know that I need to type "cscript //nologo CreateProcess.v bs TestPC %windir%\system 32\notepad.exe %temp%" into command prompt, but I'm stuck on what to put in the script file. I have an outline of what to put from a site:
Code:
Dim sComputer . Dim sCmdLine C:\Windows\notepad.exe Dim sCurDir C:\Windows\notepad.exe Dim oProcess 'object representing the Win32_Process class Dim oMethod 'object representing the Create method Dim oInPar 'object representing input parameters of the method Dim oOutPar 'object representing output parameters of the method sComputer = WScript.Arguments(0) sCmdLine = WScript.Arguments(1) sCurDir = WScript.Arguments(2) Set oProcess = GetObject("winmgmts://" & sComputer & _ "/root/cimv2:Win32_Process") Set oMethod = oProcess.Methods_("Create") Set oInPar = oMethod.inParameters.SpawnInstance_() oInPar.CommandLine = sCmdLine oInPar.CurrentDirectory = sCurDir Set oOutPar = oProcess.ExecMethod_("Create", oInPar) If oOutPar.ReturnValue = 0 Then WScript.Echo "Create process method completed successfully" WScript.Echo "New Process ID is " & oOutPar.ProcessId Else WScript.Echo "Create process method failed" End If
Firstly, is this correct? And secondly, what should I be putting where to start notepad.exe?
Comment