I am using PsExec to defrag machines remotely on my network. This works fine in my c# code, but because it also does a bunch of other tasks and I want it to run continuously I have converted it into a windows service.
When the code gets to the PsExec portion it exits with the code 6 which seems to mean "The handle is invalid" I have tried entering a username and password with sufficient privileges without success, I have also tried adding -s to use the system account which did not help either.
Here is the line where I set my PsExec arguements...
psexec.StartInfo.Arguments = @" \\" + machine + "/accepteula -s defrag.exe " + volume + " -f";
I have also tried...
psexec.StartInfo.Arguments = @" \\" + machine + "/accepteula defrag.exe " + volume + " -f";
psexec.StartInfo.Arguments = @" \\" + machine + "/accepteula defrag.exe " + volume + "-u myuser -p mypass -f";
Any help would be greatly appreciated!! But nothing seems to fix my problem.