Re: Win32_Process.create fails to achieve aim
- From: "Jonathan Liu [MSFT]" <jonliu@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 Sep 2005 13:50:05 -0700
The Win32_Process.Create method will not run anything interactively on a
remote machine. Also if you do not have appropriate privileges on the
remote machine it will terminate without notification to this method. See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/create_method_in_class_win32_process.asp
Have you tried to run the scipt locally on the machine?
You can try and use Win32_ScheduledJob, although you will not have the
ability to launch the app right away.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
<fabre.lambeau@xxxxxxxxx> wrote in message
news:1123518001.445138.28220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Situation:
> I have a computer on which I need to launch a process that will force
> the graphic card to go in clone mode. The command line is:
> rundll32.exe NvCpl.dll,dtcfg setview 1 clone
>
> This command works when I execute it manually on the computer.
> However, I need to launch that command from another computer, ideally
> in a .Net project but it could also be via Wscript.
>
> I tried to use WMI to execute the above command remotely, with
> different credentials, but it doesn't work, nor does it return any
> error.
>
> My code is as follows:
>
> <code>
> Dim objSWbemLocator, objSWbemServices, objWMIService, objProcess
> Dim strShell, objProgram, objStartup, strComputer, strExe, inParams,
> outParams
>
> strComputer = "192.168.120.123"
> strExe = "c:\windows\system32\rundll32.exe NvCpl.dll,dtcfg setview 1
> clone"
>
> ' Connect to WMI
> Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
> Set objSWbemServices = objSWbemLocator.ConnectServer _
> (strComputer, "root\cimv2", "username", "password")
>
> ' Obtain the Win32_Process class of object.
> Set objProcess = objSWbemServices.Get("Win32_Process")
> Set objStartup = objSWbemServices.Get("Win32_ProcessStartup")
> Set inParams =
> objProcess.Methods_("Create").InParameters.SpawnInstance_
> inParams.CommandLine = strExe
> objStartup.ShowWindow = 3
> inParams.ProcessStartupInformation = objStartup
>
> 'Execute the program now at the command line.
> Set outParams = objProcess.ExecMethod_("Create", inParams)
>
> WScript.Echo "Returned: " & outParams.ReturnValue
>
> WSCript.Quit
> </code>
>
>
> The script outputs the following:
> <output>
> Returned: 0
> Exit code: 0 , 0000h
> </output>
>
> However, the command has clearly not been executed since the computer
> is still not in clone mode.
> I tried launching "calc.exe" instead of the rundll32.exe command, and a
> process calc.exe is indeed created and is visible in the list of
> processes (although the calculator window doesn't appear...)
>
> Could anyone help with this?
>
> Many thanks.
>
> Fabre Lambeau
> Inspiration Matters Ltd
>
.
- Prev by Date: Update manager field using ADSysteminfo
- Next by Date: How to run remote scripts on two different network through two different network card on the same computer
- Previous by thread: Update manager field using ADSysteminfo
- Next by thread: How to run remote scripts on two different network through two different network card on the same computer
- Index(es):
Relevant Pages
|