Forum posts for Defrag.exe

C# run defrag.exe remotely

I am trying to create a utility to defrag all machine on my network. I have had success using WMI's Defrag and DefragAnalysis methods, however they are not compatible with Windows XP. This is a problem as we have some XP machines on the network.
I have been able to locally invoke the defrag.exe process on an XP machine to perform a defrag however I am having problem invoking it on remote machines. Below is my code which works locally, could someone please help me in making this work for remote machines on my network? I have tried using a bit of WMI to help out but as I am new to C# and WMI I haven't had success, thanks!

ProcessStartInfo info = new ProcessStartInfo();
info.FileName = 'defrag';
info.Arguments = volume + ' -f';
info.UseShellExecute = false;
info.CreateNoWindow = true;
info.RedirectStandardOutput = true;

Process defrag = Process.Start(info);
defrag.PriorityClass = ProcessPriorityClass.BelowNormal;

while (!defrag.HasExited)
{
System.Threading.Thread.Sleep(1000);
Process[] procs = Process.GetProcessesByName('dfrgntfs');
if (procs != null && procs.Length > 0)
{
procs[0].PriorityClass = ProcessPriorityClass.Idle;
defrag.WaitForExit();
}

result = null;
while(!defrag.StandardOutput.EndOfStream)
{
//get output and store results
}

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.