Kondro Posted September 13, 2011 Share Posted September 13, 2011 (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 September 13, 2011 by Kondro Link to comment Share on other sites More sharing options...
AdamUL Posted September 13, 2011 Share Posted September 13, 2011 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 More sharing options...
willichan Posted September 13, 2011 Share Posted September 13, 2011 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) My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Kondro Posted September 13, 2011 Author Share Posted September 13, 2011 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! Link to comment Share on other sites More sharing options...
Kondro Posted September 13, 2011 Author Share Posted September 13, 2011 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 More sharing options...
Kondro Posted September 13, 2011 Author Share Posted September 13, 2011 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now