How to restart and shutdown pc in winPE with vb net

Here I am going to disuse How to restart and shutdown pc in WinPE with vb .net framework 4. If you don’t know how to Add framework WinPE Windows Preinstallation Environment you can visit the link.  After integration success an application with dot net framework 4.0 in WinPE, I got attention the application should have the functionality to restart and shutdown. I normally tried shutdown with its parameters /r, /s, -r, -s but surprisingly it did not work for me in vb.net. After it, I started to search on the Internet how to restart the computer in WinPE with vb.net. At last, I found “wpeutil“ command to reboot or shutdown pc in WinPE. But the issue with the command is it can only run the DOS environment, their cmd window pop up and looks too bad to me. So I have to search for some extra features to accomplish the task. The “Process” and ProcessStartInfo()commands made easy for me to compile a good application.

How to restart and shutdown pc in WinPE with vb net

Note: – the following code does not work in Windows Environment it works only in WinPE.

If you want to shutdown your PC in WinPE, simply copy the following code and paste under the button and run only in WinPE.

Dim p As New Process
Dim psi As New ProcessStartInfo()
        psi.Verb = "runas" ' runas = Run As Administrator
        psi.FileName = "cmd.exe" ' File or exe to run (this cannot take arguments, use ProcessStartInfo.Arguments instead
        psi.Arguments = "/c wpeutil shutdown"
        psi.WindowStyle = ProcessWindowStyle.Hidden
        p.StartInfo = psi
        p.Start()
        p.WaitForExit()

If you want to restart your PC in WinPE, simply copy the following code and paste under the button and run only in WinPE.

Dim p As New Process
Dim psi As New ProcessStartInfo()
        psi.Verb = "runas" ' runas = Run As Administrator
        psi.FileName = "cmd.exe" ' File or exe to run (this cannot take arguments, use ProcessStartInfo.Arguments instead
        psi.Arguments = "/c wpeutil reboot"
        psi.WindowStyle = ProcessWindowStyle.Hidden
        p.StartInfo = psi
        p.Start()
        p.WaitForExit()

Leave a Reply

Your email address will not be published. Required fields are marked *


*