Re: Win32_Process.create fails to achieve aim

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>


.



Relevant Pages

  • Re: How to detach from remote command?
    ... until the command finishes. ... Suppose I write a program vfork on the remote machine. ... is execute those arguments via execlp. ...
    (comp.os.linux)
  • problem about executing a command without remote shell
    ... I want to execute a command on the remote machine with ssh client, ... But if I first login into the remote machine and then execute the same ...
    (comp.security.ssh)
  • Expect and rsh
    ... I have an expect script that I use to telnet into a remote machine ... to execute unix commands. ... For example, myscript takes a command, "-c", and executes it on ... When I do an rsh to a third machine, mach2, via mach1, I get ...
    (comp.lang.perl.modules)
  • Re: expect + last few arguments as one
    ... I'm trying to execute some commands on remote machines using expect ... ... I execute this script like: ... ./ssh_login.sh PASSWD IP COMMAND ... to different text file (on remote machine as well) AND here i have problem ...
    (comp.os.linux.misc)
  • [Full-Disclosure] Advanced usage of system() function.
    ... and call its arguments as a command for shell. ... as we can see we still didnt get what we want (typing exit ... Connection closed by foreign host. ... think what we want to execute. ...
    (Full-Disclosure)