Forum posts for Defrag.exe

Exitcode 6 using PsExec in Windows Service

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.

View complete forum thread with replies

Other posts related to Defrag.exe

See Related Forum Messages: Follow the Links Below to View Complete Thread

Can't call defrag from perl script on Windows 2008
C# run defrag.exe remotely
Real Time CMD Output on Windows Defrag.exe
Exitcode 6 using PsExec in Windows Service
Schedule using “at” CMD in LOOP
Process.Start in WindowsSystem32 folder
Batch File Creating Text File With Date
what the best and simplest way to find out whether a volume need defrag?
How do I create a batch script that creates a task for a specific user in the Active Directory?
C# How to Get Output from CMD (Command = “Defrag c: /U”) Before Proccess Ends.

What is the carbon footprint of your coffee?

Is it low? Is it high? Can this things really kill the planet Earth? Maybe the answer will surprise you. Maybe not.