• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

WSH? Any Answers?!?

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 brought this back from the farm where they grow the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic