Jump to content

Reboot Script


Kondro
 Share

Recommended Posts

hello, i have a script with a full GUI that works great for slecting computers by checkbox and then clicking a button to reboot them. the checkboxes are each pointed to a different machine staically by Func. code is like this for each.

Run (@ComSpec & " /c " & "shutdown -r -m \\computername -t 30", @SystemDir, @SW_HIDE)

Im trying to write a smaller script for a different purpose but similar effect. I want the script to prompt the user for the computer name to reboot and then have it reboot that machine. so here is what i wrote, but it does not work. it prompts for the computer name but does not send the reboot command to that machine. I know its likely a small syntax error, but i get no error from Scite when i run it.

$Computername=InputBox("Reboot Program", "Please enter the computername to reboot", "","*", -1, -1, 0, 0)

Run (@ComSpec & " /c " & "shutdown -r -m" & $Computername & "-t 30", @SystemDir, @SW_HIDE)

Edited by Kondro
Link to comment
Share on other sites

You are missing spaces in your Run command, after -m and before -t.

Try

$Computername=InputBox("Reboot Program", "Please enter the computername to reboot", "","*", -1, -1, 0, 0)
Run (@ComSpec & " /c " & "shutdown -r -m " & $Computername & " -t 30", @SystemDir, @SW_HIDE)

Adam

Link to comment
Share on other sites

You are also missing the double backslash before the computer name.

$Computername=InputBox("Reboot Program", "Please enter the computername to reboot", "","*", -1, -1, 0, 0)
Run (@ComSpec & " /c " & "shutdown -r -m \\" & $Computername & " -t 30", @SystemDir, @SW_HIDE)
Link to comment
Share on other sites

Thank you, the script works now but found another snag, if i dont put anything into the msg box or click cancel or close it reboots my computer, LOL for a moment there i thought i may have rebooted all the computers in the domain... LOL but it just rebooted mine. ANy ideas on a way to have it exit if no value has been entered or/and if the cancel/X button is clicked?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...