Sign in to follow this  
Followers 0
Kondro

Reboot Script

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Thank you both! and thanks for the \\ tip, i was thinking that i would have to instruct the end user to put the slashes in, if it can be added to the script and works that will be AWESOME! Thank you again!

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

nevermind, i added this and it works fine if nothing is entered, or the cancel button is clicked, or if the Close X is clicked

$nogood=("")

If $Computername=$nogood Then

Exit

EndIf

Share this post


Link to post
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
Sign in to follow this  
Followers 0