none
WMI Process Call Create gives good feedback but doesn't work RRS feed

  • Question

  • I'm developing a VB.NET application able to control remotely other computers, send commands and retrieve information


    Here's the code:

     Dim connOptions As ConnectionOptions = New ConnectionOptions()
                            connOptions.Impersonation = System.Management.ImpersonationLevel.Impersonate
                            connOptions.Authentication = System.Management.AuthenticationLevel.Packet
                            connOptions.EnablePrivileges = True
                            Dim theScope As ManagementScope = New ManagementScope("\\" & IPAddressTextBox.Text & "\root\cimv2", connOptions)
                            Dim theClass As New ManagementClass(theScope, New ManagementPath("Win32_Process"), New ObjectGetOptions())
                            Dim iPe As ManagementBaseObject = theClass.GetMethodParameters("Create")
    
    
                            iPe("CommandLine") = CommandLineTextBox.Text
                            theClass.InvokeMethod("Create", iPe, Nothing)

    The problem is that even if it gives a "0" ReturnValue, which means the operation is successful, the process doesn't actually starts on the remote machine (which is in the local network)  

    In reality, the process actually starts but doesn't show up, in the Task Manager of the remote machine, is visible ONLY under "Processes" -> "Show processes from all users", at this point, i can see the process i created from the other main machine, the process "User Name" is the main computer username, and not the remote machine one, is that the problem?

    I'm using Impersonate as the impersonation level and Packet as the Authentication level (as you can see from the code), is this what i'm doing wrong?

    also it doesn't work with WMIC with "wmic /NODE:IPADDRESS process call create COMMANDLINE"

    Thanks you for your time.

     
    Tuesday, November 4, 2014 2:40 PM

Answers

  • It doesn't matter whether you use VB, VBScript, or PowerShell. If you use any of these languages to create a process on a remote machine using WMI, the new process is always going to run in the background. You cannot make it run as a visible process. This is by design and is explicitly stated in the Remarks section of the method's documentation:

    http://msdn.microsoft.com/en-us/library/aa389388.aspx

    For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, November 5, 2014 4:07 PM
    Moderator

All replies

  • You cannot start an interactive process on a remote computer using WMI, if that is what you are asking. This is for security reasons.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, November 4, 2014 3:17 PM
    Moderator
  • You need to post VB questions in the  VB forum.

    I recommend that you read the documentation on Process.Create and the WMI implementation as well as searching for articles on how this works.

    Try to learn the basic of WMI and its implementation.  It is important that you know that in order to program to it.


    ¯\_(ツ)_/¯

    Tuesday, November 4, 2014 3:17 PM
  • It doesn't matter whether you use VB, VBScript, or PowerShell. If you use any of these languages to create a process on a remote machine using WMI, the new process is always going to run in the background. You cannot make it run as a visible process. This is by design and is explicitly stated in the Remarks section of the method's documentation:

    http://msdn.microsoft.com/en-us/library/aa389388.aspx

    For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, November 5, 2014 4:07 PM
    Moderator