Note that there are some explanatory texts on larger screens.

plurals
  1. POwin32_process.create does not show window
    text
    copied!<p><br> I'm trying to create a process on a remote machine using C#. <br><br> I get all the needed parameters, and I actually succeed in running the process, but I can't see the window. <br> For example, here I'm trying to run a notepad process, but no window is showing up, only a notepad.exe process in the Task Manager.</p> <pre><code> public void ExecuteOnRemote(string username, string password) { ConnectionOptions connOptions = new ConnectionOptions { Impersonation = ImpersonationLevel.Impersonate, EnablePrivileges = true, Username = username, Password = password }; ManagementScope scope = new ManagementScope(@"\\remoteMachineName\root\cimv2", connOptions); scope.Connect(); ObjectGetOptions options = new ObjectGetOptions(); // Getting the process class and the process startup class ManagementPath processClassPath = new ManagementPath("Win32_Process"); ManagementPath processStartupClassPath = new ManagementPath("Wind32_ProcessStartup"); ManagementClass processClass = new ManagementClass(scope, processClassPath, options); ManagementClass processStartupClass = new ManagementClass(scope, processStartupClassPath, options); // Settings the show window parameter in for a process startup class instance ManagementObject processStartupInstance = processStartupClass.CreateInstance(); processStartupInstance["ShowWindow"] = 1; // A const value for showing the window normally // Settings the parameters for the Create method in the process class ManagementBaseObject inArgs = processClass.GetMethodParameters("Create"); inArgs["CommandLine"] = "notepad.exe"; inArgs["ProcessStartupInformation"] = processStartupInstance; // Invoking the method ManagementBaseObject returnValue = processClass.InvokeMethod("Create", inArgs, null); } </code></pre> <p>My guess is that I'm sending the ProcessStartupInformation parameter wrong, but I still can't figure out where is the problem. <br> Any help would be appreciated. <br> Thanks a lot, Alex.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload