Let’s say I have a windows service called ‘MyService’ and an executable called ‘MyEXE’ located on several computers on my network.
Is it possible (from within ‘MyService’) to start several instances of ‘MyEXE’ on a different/same computer, have it do some task and return a true/false result to a callback method in ‘MyService’?
Something like this
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); } }
Maybe I’m getting the whole architecture wrong!
You could use PSexec as Ian stated, but I think WMI is a better way try this for an example http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx