Results 1 to 7 of 7

Thread: [RESOLVED] VB.NET 2008 Remote Process Starting

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Resolved [RESOLVED] VB.NET 2008 Remote Process Starting

    Hello, the below code starts the correct process but the windows form never displays on the remote machine. How do I get the application to actually load.

    Code:
        Private Sub RunRemoteProcess()
            Dim sCmd As String = "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & txtData.Text.Trim
    
            ' add a reference to System.Management in Solution Explorer
    
            Dim wmi As ManagementClass
            Dim wmi_in, wmi_out As ManagementBaseObject
            Dim retValue As Integer
    
            Try
                wmi = New ManagementClass("\\" & HostName & "\root\cimv2:Win32_Process")
                ' get the parameters to the Create method
                wmi_in = wmi.GetMethodParameters("Create")
                ' fill in the command line plus any command-line arguments
                ' NOTE: the command can NOT be on a network resource!
                wmi_in("CommandLine") = sCmd
                ' do it!
                wmi_out = wmi.InvokeMethod("Create", wmi_in, Nothing)
                ' get the return code.  This not the return code of the
                ' application... it's a return code for the WMI method
                retValue = Convert.ToInt32(wmi_out("returnValue"))
                Select Case retValue
                    Case 0
                        ' success!
                    Case 2
                        Throw New ApplicationException("Access denied")
                    Case 3
                        Throw New ApplicationException("Insufficient privilege")
                    Case 8
                        Throw New ApplicationException("Unknown failure")
                    Case 9
                        Throw New ApplicationException("Path not found")
                    Case 21
                        Throw New ApplicationException("Invalid parameter")
                    Case Else
                        Throw New ApplicationException("Unknown return code " & retValue)
                End Select
            Catch ex As Exception
                MsgBox(HostName & ": Can't create the process. " & ex.Message)
            End Try

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: VB.NET 2008 Remote Process Starting

    make sure that you pass admin privileges (impersonation).
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Re: VB.NET 2008 Remote Process Starting

    Quote Originally Posted by sapator View Post
    make sure that you pass admin privileges (impersonation).
    How would I go about doing the impersonation using the above code? I've seen other examples of wmi process creation but they don't seem to work properly. This example here at least is creating the process on the remote machine that I can see.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: VB.NET 2008 Remote Process Starting

    Hi.
    A general example is:
    Code:
     Dim imp As New System.Management.ConnectionOptions
    imp.Username = strUserName
    imp.Password = strPassword
    imp.Impersonation = Management.ImpersonationLevel.Impersonate
    impt.Authentication = Management.AuthenticationLevel.PacketPrivacy
    U use it after with ManagementScope

    Haven't used impersonation for what u are doing so let us know if you can make it work.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Re: VB.NET 2008 Remote Process Starting

    I've come to the conclusion that it is impossible to run a process on the remote machine as the currently logged in user and have it display the new processes windows form on the users winstation. I have tried almost everything.

  6. #6
    New Member
    Join Date
    Apr 2010
    Posts
    2

    Re: [RESOLVED] VB.NET 2008 Remote Process Starting

    There is a simple answer to your problem. Under normal circumstances processes started remotely are prohibited from running interactively. The issue is explained in the following MSDN link.

    http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Re: [RESOLVED] VB.NET 2008 Remote Process Starting

    Hi,

    Thanks for that bit of info. It actually gave me the encouragement to start playing with this remote process execution again. I am basically trying to re-create what psexec does. So I'm assuming that I will have to have a service running on the localmachine and have the service's code create the Win32_Process.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width