Hi Again,
I’ve been looking into different ways of invoking commands on remote machines. Here’s one that can be used in VB.NET by using WMI.
First add a reference to System.Management and reference it at the start of your project:
1 |
Imports System.Management |
Then add the guts, the code that calls WMI on the remote machine to open the process:
1 2 3 4 5 6 7 8 |
Dim RemoteComputer = "Your PC Name" Dim ProcessToLaunch = {"C:\windows\system32\notepad.exe"} Dim connOptions As ConnectionOptions = New ConnectionOptions() connOptions.Authentication = AuthenticationLevel.PacketPrivacy connOptions.Impersonation = ImpersonationLevel.Delegate Dim mgmtScope As ManagementScope = New ManagementScope("\\" & RemoteComputer & "\root\cimv2", connOptions) Dim mgmtClass As New ManagementClass(mgmtScope, New ManagementPath("Win32_Process"), New ObjectGetOptions()) mgmtClass.InvokeMethod("Create", ProcessToLaunch) |
This will launch the process under the credentials of the user that ran the command. I tried to play around with impersonation but haven’t had much luck. In fact I chose to go down another route to launch my remote process as I had no luck with impersonation.
If any of you have had success using impersonation, or know another method to invoke a command as another user (using VB/C# .NET) let us know!