Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need more then one input box on remote shutdown tool

Status
Not open for further replies.

Sasstraliss

Programmer
Apr 7, 2009
21
AU
Here's my code so far,
and what is does is limited because it only has one dialog box, meaning that to shutdown multiple computers, you need to open up more then one instance of the program.

What I'd like to do is change the code so that you have 3 input box's, so that by filling in the computer names to all 3 box's, then all of them would shutdown at once.

Also, I would like it so that the script does not stuff up if one of the box's is left empty.

Any help on this would be greatly appreciated, here's my script so far. (Only allows one text box)

Code:
Dim objShell, strComputer
Dim strShutdown

strComputer = (InputBox(" ", "Internet Explorer (Not Responding)"))
If strComputer <> "" And strComputer <> "q" And strComputer <> "w" And strComputer <> "e" And strComputer <> "r" And strComputer <> "t" And strComputer <> "y" And strComputer <> "u" And strComputer <> "i" And strComputer <> "o" And strComputer <> "p" And strComputer <> "a" And strComputer <> "s" And strComputer <> "d" And strComputer <> "f" And strComputer <> "g" And strComputer <> "h" And strComputer <> "j" And strComputer <> "k" And strComputer <> "l" And strComputer <> "z" And strComputer <> "x" And strComputer <> "c" And strComputer <> "v" And strComputer <> "b" And strComputer <> "n" And strComputer <> "m" Then

    strShutdown = "shutdown -s -t 0 -f -m \\" & strComputer

    Set objShell = CreateObject("WScript.Shell")

    objShell.Run strShutdown
    
End If

Wscript.Quit
 
How about using a loop? Something like:
Code:
Dim objShell, strComputer
Dim strShutdown
Dim iCounter

for iCounter = 1 to 3

strComputer = (InputBox(" ", "Internet Explorer (Not Responding)"))
If strComputer <> "" And strComputer <> "q" And strComputer <> "w" And strComputer <> "e" And strComputer <> "r" And strComputer <> "t" And strComputer <> "y" And strComputer <> "u" And strComputer <> "i" And strComputer <> "o" And strComputer <> "p" And strComputer <> "a" And strComputer <> "s" And strComputer <> "d" And strComputer <> "f" And strComputer <> "g" And strComputer <> "h" And strComputer <> "j" And strComputer <> "k" And strComputer <> "l" And strComputer <> "z" And strComputer <> "x" And strComputer <> "c" And strComputer <> "v" And strComputer <> "b" And strComputer <> "n" And strComputer <> "m" Then

    strShutdown = "shutdown -s -t 0 -f -m \\" & strComputer

    Set objShell = CreateObject("WScript.Shell")

    objShell.Run strShutdown
    
End If

Loop

Wscript.Quit
Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
It's possible, but I'd like the original dialog box to have all 3 text windows, so that one button will do all three.
 
Unfortunately you can't do that with a standard inputbox how you describe. You could have users enter the computers comma delimited in the inputbox and seperate them out after and do it like that though.

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Here's a quick example using an array and Split():
Code:
Dim objShell, strComputer
Dim strShutdown
Dim strComputers
dim i

strComputer = (InputBox(" ", "Internet Explorer (Not Responding)"))

strComputers = Split(strComputer, ",")

For i = 0 to Ubound(strComputers)
	msgbox strComputers(i)
next


Wscript.Quit
You pass in the comma delimited string from the inputbox and then split seperates each element into an array value. The script then loops the array and outputs the value to the user.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top