简体   繁体   中英

How to open windows Defragmenter tool using vb.net?

I am trying to open Windows default Defragmenter tool using the following code : Process.Start("dfrgui.exe")

It is for Windows 7 32 bit and is working perfectly. I want this code to work with Windows 7 64 bit too.

What change is required in my code?

Just tested and had same issue but then looked at the Target CPU and when set to x64 it works. Then noticed just below there is an option for "Prefer 32-bit" If you uncheck this then it'll work on any system :-)

Regards

Liam

I hope this can help you.

Firstly, You need to compile your code for x64 as target or you can use "Any CPU", depends of you.

目标CPU

After that you can use:

System.Diagnostics.Process.Start("dfrgui.exe")

If you want to start an application "As Admin" you will have to do something like this (This piece of code was taken from here ):

Dim procStartInfo As New ProcessStartInfo
Dim procExecuting As New Process

With procStartInfo
    .UseShellExecute = True
    .FileName = "yourApp.exe"
    .WindowStyle = ProcessWindowStyle.Normal
    .Verb = "runas" 'add this to prompt for elevation
End With

procExecuting = Process.Start(procStartInfo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM