File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes WSH? Any Answers?!? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "WSH? Any Answers?!?" Watch "WSH? Any Answers?!?" New topic
Author

WSH? Any Answers?!?

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 826
Im trying to use the WScript object but when I try accessing a function (with the WScript object being used) it gives me a "WScript is undefined" error dialog box. Does anyone know how I can start using Windows Host Scripting (especially use the Echo method of it)?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You will have to do the following:
1) be writing client-side script on a windows PC for a windows PC.
2) create an instance of the WScript object you are interested in using.
Here is an example I lifted from MSDN:

You can find the WSH reference here.
HTH
[ April 12, 2002: Message edited by: Bodie Minster ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

Sorry Bodie maybe I should have explained a bit farther. You see Im trying to use the WScript object like this :
WScript.Echo(<whatever text> ;
Basically this is the only line in the code with WScript being used.
Its giving me the error like I showed before so it doesnt seem like its set up right. Does that make sense? I was thinking it needed a path setup or something related to configuration. Correct me if Im wrong but is WSH automatically accessible if using Javascript or JScript in the language of the script. Thanks again for your response before and any input you can give for this question.
Rob

WSH is designed to be run outside the context of a browser. To use it in an HTML page, you will have to create an instance of some WSH object, just as you would for any other ActiveXObject. I haven't tried this yet, but you should be able to do something like this:
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I should also mention that the script engine that handles WSH ships with 98, me, 2000, and XP, but not with older OS's or non-M$ OS's.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Well, I've done a little more looking into this and I have found the following:
1) WSH is intended to run standalone scripts.
2) it can be used as an ActiveX object, but you can't directly create an instance of the WScript object in this way.
3) If you create a .js file on your desktop and try using the Wscript.echo() you will have no troubles. Executing this in the browser presents a problem.
I have not been able to figure out how to create an instance of "WScript.WScript" as an ActiveXObject. I was successful in creating "WScript.Shell" and executing some of its methods.
Perhaps this would be a good time to step back and ask what is your ultimate goal with WSH? Maybe there is an easier or otherwise better way to get the job done?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 826
Bodie,
Thanks for all the replys. I've been looking into alternative ways of handling printing to a printer but with no luck. There are ways of doing it but there is way too much fooling around to do it. I can see why so many people just use printer-friendly pages. I was, however, wondering how Chapters allows their customers to print their orders directly to a printer in their in-store kiosks (or at least it's what I heard).
Rob
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
window.print()
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/printtemplate2.asp
as Sgt Schultz says
"I know Nothing"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WSH? Any Answers?!?