Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WScript.Echo 1

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
IE
I don't know VBscript at all but I know VB well. I am trying to learn VB script. I have found numerous examples that use the above but I get Error Object required WScript when I run them.
 
Are you running them inside an ASP page?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
No. Is that the problem (i.e. it should be within an ASP page)
 
Nope...perhaps post some sample code.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Here is a simple example. I suppose I'm using it in the wrong context.

<html>
<head>
</head>
<body><script type="text/vbscript">
document.write "This works"
WScript.Echo "This gives an error"

</script></body>
</html>
 
Ok, so you are running it in a web page (not asp admittedly but a web page none the less). So use MsgBox instead of WScript.Echo.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I'm just curious as to why.

in a .vbs file WScript.echo "XXX" doesn't work

in a .js file WScript.echo("XXX"); works
 
Show us a VBS file where WScript.Echo does not work. I have never had an issue with that. What you posted before was HTML with embedded VBS.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
The line is as above. There is nothing in the file.
 
So you put just this line:

WScript.Echo "XXX"

into a file named foo.vbs. Then double click foo.vbs and you get an error?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Yes, that's correct. But in a javascript with javascript syntax it works fine.
 
That would be indicative of a corrupt Windows Script Host installation or configuration. You might want to uninstall and re-install.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I re-installed Windows Script Host but it's still the same.
 
>in a .vbs file WScript.echo "XXX" doesn't work
What do you mean "doesn't work"???! I suppose it does not mean there be an error message coming from wsh!? The basic thing you have to check the file association to .vbs. The default action "open" should look something like this or some variation of it if you'd edited it.
[tt] C:\WINDOWS\System32\WScript.exe "%1" %*[/tt]
 
Then it is something in your environment. That is a hard thing to troubleshoot without access to your environment. Just to be sure that we are all on the same page, please follow these steps:

1) Open a command prompt
2) Type: cd \temp <ENTER>
3) Type: echo WScript.Echo "XXX" > foo.vbs <ENTER>
4) Type: cscript.exe foo.vbs <ENTER>

Verify that you then get an error and please post the error that you get.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks, EBGreen. That worked. When I run it from windows I dont see the output. In javascript I see a message box. I guess thats just the way it operates (i.e. in VB script you can only see the output if you run from the command line). Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top