Programatically Restarting a Computer

Hi all,

Can someone let me know how I can programatically make the users computer restart (as it needs to do this after an install)
Many Thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can make a batch file (.bat) In it, put for example:

shutdown /r  \\Computername

See all the commands here
I said batch file assuming you want to reboot more than one computer at once. If you just need to reboot one, you can do this from the command line.

You can also make this a scheduled task:

Control Panel >  scheduled tasks > add scheduled task.  Browse to the batch file, and click finish.
kiranboiAuthor Commented:
i only need to shutdown one computer. just the one the user is logged on to at the time.

how can i do this from the command line? any chance of a code example?
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).


shutdown /r  \\Computername

Computername is the name of the computer you are sitting on. I think if you do "shutdown /r" without computer name, that should work as well.

/r is reboot
kiranboiAuthor Commented:
im still not clear how to implement this.i have tried the code below but it doesnt work:

Dim ps As New Process
            Dim psi As New ProcessStartInfo
            With psi
                .FileName = "cmd"
                .Arguments = "shutdown /r"
                .UseShellExecute = False
                .WindowStyle = ProcessWindowStyle.Hidden
            End With
            With ps
                .StartInfo = psi
            End With

any suggestions?
Oh, I just noticed you were referring to .NET.

I'm not too sure on that, but I will let you know what I find.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.