繁体   English   中英

我想在远程Windows机器上复制并运行.exe文件?

[英]I want to copy and run .exe file on a remote Windows machine?

我已经复制了exe文件,没有问题,使用下面的代码,但现在我想运行它,anyboyd可以帮助我。 注意:我可以通过远程桌面访问服务器,但不能手动执行此操作,因为有几十个,无法像psex或其他任何方式在其上运行程序。

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");
}

根据您在服务器上的访问权限,您可以使用psexec等程序或使用WMI远程启动文件。

一个样本psexec命令就是

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

如果请求,Psexec可以预先复制文件,并且可以针对计算机列表运行(用@computer-list.txt替换\\\\computername )。 使用WMI,您需要连接到Win32_Process类并创建一个新对象来启动它。 这个帖子中的第二篇文章可行。

不幸的是,这两个选项都需要从运行的工作站获得多个防火墙规则(如RPC和WMI)。 如果您的公司仅通过防火墙启用了RDP访问,则这些都不会起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM