Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

msgbox vs Wscript.echo

2,904 views
Skip to first unread message

Thomas Scheiderich

unread,
Aug 21, 2002, 8:47:49 PM8/21/02
to
When using VBScript, when would I use msgbox over Wscript.echo? Does it
matter?

Tom.

Torgeir Bakken

unread,
Aug 21, 2002, 9:06:20 PM8/21/02
to
Thomas Scheiderich wrote:

> 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


Thomas Scheiderich

unread,
Aug 22, 2002, 12:42:48 AM8/22/02
to
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), why would you use one over the other - or does it matter?

Thanks,

Tom

Joe Fawcett

unread,
Aug 22, 2002, 7:19:33 AM8/22/02
to
"Thomas Scheiderich" <t...@deltanet.com> wrote in message
news:3D646BC8...@deltanet.com...

> 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), why would you use one over the other - or does it matter?
>
> Thanks,
>
> Tom
>
> Torgeir Bakken wrote:
>
> > Thomas Scheiderich wrote:
> >
> >
> >>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.
> >
It also gives you more control over the icons and title text.

Joe


Torgeir Bakken

unread,
Aug 22, 2002, 7:35:42 AM8/22/02
to
Thomas Scheiderich wrote:

> 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


0 new messages