GreyHippo
GreyHippo

Reputation: 263

VBscript ends without user input

I am having a problem with VB scripts on a Windows 7 computer. When I try and run any *.vbs file, it runs the script but does not pause for user input. The code below runs but it does not pause for the echo statement. On other computers it will pause for the user to press the Ok button. What do I need to change on the computer which does not allow it to pause?

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

strPath = "c:\temp"
Set objFolder = objFSO.GetFolder(strPath)
Wscript.Echo objFolder.Size

or

Input = InputBox("Enter Project Number: ")
Wscript.Echo Input

Upvotes: 0

Views: 509

Answers (2)

AutomatedChaos
AutomatedChaos

Reputation: 7500

As the mapping to CScript is a good suggestion and should work, as an alternative you can use the MsgBox statement in your script. This shows a message box independently if you are running under CScript or WScript:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

strPath = "c:\temp"
Set objFolder = objFSO.GetFolder(strPath)
MsgBox objFolder.Size

Upvotes: 0

Nathan Rice
Nathan Rice

Reputation: 3111

Map your VBScript to wscript.exe instead of cscript.exe.

Right click -> Open With... -> Ensure "Always use the selected program to open this kind of file" check box is checked -> Click the "Browse..." button -> "C:\Windows\System32\wscript.exe" -> Open -> OK

Upvotes: 1

Related Questions