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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't call WScript

Status
Not open for further replies.

johnbuckley

Technical User
Mar 25, 2002
52
0
0
GB
I'm trying to run a function using WScript, with the line

var oShell=WScript.CreateObject("WScript.shell")

However this only produces the error 'WScript is not defined'

Wscript is installed. If you put the function code in a text file with a .js extension it runs OK in windows.

Any ideas please?

John
 
I'm not up on this but it appears that you're trying to create a Wscript instance through javacript. The error you're getting is because you're using the DOT operator in your call WScript.CreateObject( and javascript doesn't know anything about Wscript. I would think that you would first have to call Wscript (starting it in the background) and then make a call to your shell object.

I hope I'm making a little sense and maybe am pointing oyu in the right direction...

There's always a better way. The fun is trying to find it!
 
I see what you mean but I'm not sure. I copied the code from numerous examples shown on Tek-Tips and they don't follow your line.

Thanks anyway
I'll keep looking

John
 
i believe the jscript syntax would be

var oShell = new ActiveXObject("WScript.shell");



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top