![]() |
|
[.NET] Defrag harddrive using WMI - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Defrag harddrive using WMI (/showthread.php?tid=5032418) |
Defrag harddrive using WMI - Rockofello - Oct 23, 2015 Here I have a simple Process creator and I want to use WMI to defrag the hard drive selected and show a progress bar while it works, here is what I have DefragForm.vb Code Imports System.ManagementThere errors show on MyProcess.Start() "Failed to find directory" * - stratex - Oct 24, 2015 I'm on mobile so excuse me if some of this is wrong, but I'll try my best. As long as defrag.exe is running, the commandline aruments that should be passed are: Code defrag volume [-a] [-f][-v] [-?]So I believe that the ProcessStartInfo should read: Code Dim myProcessStartInfo As New ProcessStartInfo("c:\Windows\System32\Defrag.exe", "C")I'm not sure what your /U argument does but -a is to only analyse the drive which isn't what you said you were wanting. Although I think this could all be done by using: Code Process.Start(<path to defrag>, "C")I honestly have no idea if this works as I can't test it, so if this wasnt what you were looking for, a quick google search came up with a detailed walkthrough on how to do this with the built in Windows Defragger and WMI mobile.codeguru.com/columns/vb/defragging-disks-with-vb.net.htm * - Rockofello - Oct 24, 2015 Here what I got from that little snippet Code Private Sub btnDefragWMI_Click( sender As Object, e As EventArgs) Handles btnDefragWMI.Click |