Require `Enter` from the user to close the console window.
Cat's Eye Technologies
13 years ago
0 | ' Force this WSH script to run in a console window, | |
1 | ' even if it is started by double-cliking the .vbs file | |
0 | ' This technique forces this WSH script to run in a console window, | |
1 | ' even if it is started by double-clicking the .vbs file | |
2 | 2 | ' in Windows Explorer. |
3 | ||
4 | ' I don't know if this will actually work or not yet :/ | |
5 | 3 | |
6 | 4 | Option Explicit |
7 | 5 | Dim WshShell |
6 | Dim I | |
7 | Dim Pause | |
8 | 8 | |
9 | 9 | If InStr(UCase(WScript.FullName), "CSCRIPT") = 0 Then |
10 | 10 | Set WshShell = WScript.CreateObject("WScript.Shell") |
11 | WshShell.Run "CScript //Nologo " & WScript.ScriptFullName, 1, True | |
11 | WshShell.Run "CScript //Nologo " & WScript.ScriptFullName & " /Pause", 1, True | |
12 | 12 | Else |
13 | 13 | WScript.Echo "This should appear in a Console window" |
14 | 'Remainder of your script goes here | |
15 | Pause = False | |
16 | For I = 0 to WScript.Arguments.Count - 1 | |
17 | If WScript.Arguments(I) = "/Pause" Then | |
18 | Pause = True | |
19 | End If | |
20 | Next | |
21 | If Pause Then | |
22 | WScript.Echo "[Press Enter to close this window]" | |
23 | WScript.StdIn.ReadLine | |
24 | End If | |
14 | 25 | End If |