Exitcode 6 using PsExec in Windows Service
Asked Answered
O

1

6

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.

Ornithomancy answered 3/1, 2013 at 19:22 Comment(2)
I also did connect to the machines in question from the server the code is running on directly via \\machine\c$ while logged into the myuser\mypass account to ensure I could access the administrative share and I was successful...please any help would be great I am stumped and getting very frustratedOrnithomancy
I am also facing this issue :(Anticline
P
1

I know this has been open a long time, but did you find a stuck psexec service on the remote machine?

What we found was the PsExec service entry was still in Services and PsExeSvc was still in C:\WINDOWS folder.

We deleted exe from C:\WINDOWS and ran “sc delete PsExec” from an elevated command prompt to get rid of service.

Pseudaxis answered 11/10, 2019 at 18:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.