Jump to content

Recommended Posts

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
Posted

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

Posted

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)
Posted

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!

Posted

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?

Posted

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

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
  • Recently Browsing   0 members

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