假设我的网络上有几台计算机上有一个名为“MyService”的Windows服务和名为“MyEXE”的可执行文件。如何在另一台计算机上运行进程.net
是否可以(从“MyService”中)在不同的/同一台计算机上启动多个“MyEXE”实例,让它执行一些任务并将真/假结果返回给“MyService”中的回调方法?
像这样的事情
class MyService : ServiceBase
{
delegate void UpdateCallBack(int id, bool updated)
void CheckForUpdates()
{
bool updatesExist = someService.GetCurrentVersion() != currentVersion;
if(updatesExist)
{
UpdatePC("C:\Program Files\MyApp.exe", 1, UpdateComplete);
UpdatePC("\\somepc\Program Files\MyApp.exe", 1, UpdateComplete);
UpdatePC("\\mypc\Program Files\MyApp.exe", 1, UpdateComplete);
}
}
void UpdatePC(string filePath, int id, UpdateCallBack callback)
{
//This is where I am kind of lost
SomeEXERunner runner = new SomeEXERunner();
runner.Run(filePath,"-u",id,callback);
}
void UpdateComplete(int id, bool updated)
{
//do something
if(!updated)
EmailService.NotifyAdmin("PC Not updated", id);
}
}
也许我得到了整个架构错了!
+1,PS Exec是在远程机器上运行exe的方式。不管谁给了downvote,你可以说为什么,PS Exec有什么问题?没有评论的Downvotes是毫无意义的。 – 2009-04-22 14:33:58