2

I was writing a vbs script which had an output to the console using the WScript.Echo command to let the user know what iteration the program was at. This worked fine until I was working on it again today when all of a suddent the script is echoing the message as a popup box. I stripped the code down to the bare bones and its still doing it and I am completely baffled.

Option Explicit

Call F

Sub F()
    Dim TimeInterval
    Dim CycleCount
    Dim CycleCounter

    TimeInterval=FormatNumber(WScript.Arguments(0),0)
    CycleCount=WScript.Arguments(1)
    CycleCounter = 0

    For CycleCounter = 1 To CycleCount
        WScript.Sleep(TimeInterval)
        WScript.Echo "Iteration " & CycleCounter & " / " & CycleCount
    Next
End Sub

I don't see it being the code that is causing it but rather the environment it is being run in but I'm not sure how I'd go about checking where to alter the settings or how the settings were even altered in the first place.

Mason
  • 139
  • 1
  • 12

1 Answers1

4

It will display a popup if you're using Wscript.exe to run your script. It will display in the console if you're using CScript.exe to run your script.

See this (among many other resources on the web): Should we use CScript.exe or WScript.exe to run .vbs files?

Community
  • 1
  • 1
rory.ap
  • 34,009
  • 10
  • 83
  • 174
  • That would definetly explain it, goes to show the weirdest problems often have the simplest solutions. – Mason Nov 20 '14 at 16:37