我想通过Python代码检查并关闭另一台PC上运行的程序。 要关闭程序的PC通过LAN连接
我已经在C#中有了这样做的代码。但我不知道它在Python中的等效方式
string processName = "some_program.exe";
ManagementScope scope;
ConnectionOptions connectoptions = new ConnectionOptions();
connectoptions.Impersonation = ImpersonationLevel.Impersonate;
connectoptions.EnablePrivileges = true;
scope = new ManagementScope(@"\\" + RemotePCIpAddress + @"\root\cimv2", connectoptions);
// WMI query
var query = new SelectQuery("select * from Win32_process where name = '" + processName + "'");
using (var searcher = new ManagementObjectSearcher(scope, query))
{
foreach (ManagementObject process in searcher.Get()) // this is the fixed line
{
print("Killing Process : " + processName);
process.InvokeMethod("Terminate", null);
}
}
我希望python中的程序检查进程是否在另一台PC上运行并终止它
目前没有回答
相关问题 更多 >
编程相关推荐