I want to copy and run the .exe file on a remote windows machine?

I copied the exe file and it was not a problem using the following code, but now I want to run it, can anyboyd help me with this. NOTE. I have access to the servers through the remote desktop, but I can’t do it manually, because there are dozens of them, maybe a program is running on it, for example psex or something else.

WindowsIdentity wi = new WindowsIdentity(token);

//Next I set the WindowsImportsonationContext

WindowsImpersonationContext impctx = wi.Impersonate();
System.IO.File.Copy("C:\\output.html", "\\\\PW42\\c$\\output1.html", true);
System.Diagnostics.Process p = new System.Diagnostics.Process();
try
{
    System.Diagnostics.Process.Start(@"\\PW42\c$\txt.bat");
    //runFile();
}
catch
{
    Console.WriteLine("error");
}
+3
source share
1 answer

Depending on what access you have on the server, you can use a program such as psexec or use WMI to start remotely.

An example psexec command would be

psexec \\computername -u remoteusername filepath(on remote computer) arguments

Psexec , , ( \\computername @computer-list.txt). WMI Win32_Process . .

, (, RPC WMI) . RDP , , , .

+3

Source: https://habr.com/ru/post/1762118/


All Articles