We have the PsService.exe tool provided by Windows Sysinternals to start or Stop any remote machine's service.But in order to use this exe in our C# we need to use the a traditional approach where we invoke a process from C# code.
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"C:\Path\PsService.exe";
p.StartInfo.Arguments = @"\\server64 restart spooler";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
With this approach we have very little control (exception handling, logging etc) and is a bit cumbersome to use. Is there any C# library through which we can achieve the same rather than invoking a process.
I did some Googling with very little luck.
The same applies to other tools like PsExec, PsKill etc