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!

Window Won't Go Away - Simple Problem

Status
Not open for further replies.

Sasstraliss

Programmer
Apr 7, 2009
21
AU
My problem is a simple one.
When I open the .vbe file, a windows pops up with an Ok and Cancel button as well as a text box.
The function of the program is to shutdown local network computers, and this is done through shutdown.exe after you type in the computer's name and then hit enter.

However, my problem is this:
When you hit "Cancel" on the dialog box, the window comes back. Hitting "X" also does nothing.
I would like to make those ways of exiting actually exit the dialog box, and if possible, make it so that typing "e" and pressing enter also ends the program.

Code:
Dim objShell, strComputer, strInput 
Dim strShutdown 

Do 
strComputer = (InputBox(" ", "")) 
If strComputer <> "" Then 
  strInput = True 
    exit do
    End If

Loop until strInput = True 

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

    set objShell = CreateObject("WScript.Shell") 

    objShell.Run strShutdown 

Wscript.Quit

Any help on this simple problem would be greatly appreciated.
 
The code you have loops until the user enters something in the InputBox. If you take the loop out and add in the new "e" to quit criteria you get something like (untested):
Code:
Dim objShell, strComputer
Dim strShutdown

strComputer = (InputBox(" ", ""))
If strComputer <> "" And strComputer <> "e" Then

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

    Set objShell = CreateObject("WScript.Shell")

    objShell.Run strShutdown
    
End If

Wscript.Quit
Hope this helps

HarleyQuinn
---------------------------------
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.

 
Glad I could help.

HarleyQuinn
---------------------------------
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