Tom.
> When using VBScript, when would I use msgbox over Wscript.echo? Does it
> matter?
When you run cscript.exe instead of wscript.exe, it matters very much.
Run this script with cscript.exe in a command prompt to see the difference:
MsgBox "Starting"
For i = 1 to 9
WScript.Echo i
Next
MsgBox "Finished"
--
torgeir
It writes the numbers to the screen in cscript and to a popup window
when using wscript.
If you run wscript (or just excute it - I assume it will use wscript in
this case), why would you use one over the other - or does it matter?
Thanks,
Tom
Joe
> Ok.
>
> It writes the numbers to the screen in cscript and to a popup window
> when using wscript.
>
> If you run wscript (or just excute it - I assume it will use wscript in
> this case),
Correct, wscript.exe is default, but you can change the default if you want:
cscript /? gives among other things this:
//H:CScript Changes the default script host to CScript.exe
//H:WScript Changes the default script host to WScript.exe (default)
> why would you use one over the other - or does it matter?
MsgBox function
http://msdn.microsoft.com/library/en-us/script56/html/vsfctmsgbox.asp
If you want more control of the buttons (e.g. you want a Cancel button as well),
you will need to use MsgBox (se link above).
If this is not the case, here is some views on the difference:
If your scripts gives a lot of output, and you use wscript.exe, you might get a
bit tired of pushing OK on a lot of message dialogs ;-)
Where script.exe really shines, is if your vbscript editor integrates with
cscript.exe and redirects the output from cscript into an own output window. E.g.
PrimalScript can do this. One extra bonus in Primalscript, if I have an error in
the script, I just push enter (or double click with the mouse) on the error line,
and PrimalScript will switch to the source script file window and set the cursor
on the line where the error was.
But, if you do not use an "advanced" editor or doesn't have scripts that echoes a
lot to the screen, or you don't want to add buttons, it doesn't matter which one
you use.
--
torgeir