We help IT Professionals succeed at work.

Variable is undefined: 'Wscript'

jbrahy
jbrahy asked
on
Medium Priority
3,230 Views
Last Modified: 2009-08-29
I'm trying to restart a service and I get this error.

Microsoft VBScript runtime  error '800a01f4'

Variable is undefined: 'Wscript'

/Default.asp, line 14

I've installed windows scripting engine 5.6 so I thought it would work. Any ideas?

Option Explicit
Dim objShell, intShortSleep, intLongSleep
Dim strService
Set objShell = CreateObject("WScript.Shell")

' Values set
strService = " Alerter"
intShortSleep = 1500
intLongSleep = 5500

' Cmd prompt opened
objShell.Run "cmd"
Wscript.Sleep intShortSleep

' Service stopped with 'Net' command
objShell.SendKeys "net stop" & strService
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
Wscript.Sleep intLongSleep

' Service started with 'Net' command
objShell.SendKeys "net start" & strService
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"
Wscript.Sleep intLongSleep

' Cmd prompt exited
objShell.SendKeys "Exit"
Wscript.Sleep intShortSleep
objShell.SendKeys "{Enter}"

Wscript.Echo strService & " service stopped "
WScript.Quit
Comment
Watch Question

you could probably run:

You can't run wscript.sleep from ASP.

There's a very good reason for this, too:

http://blogs.msdn.com/ericlippert/archive/2003/10/07/53155.aspx

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
ignore the first line of my response :p

Commented:
Simply installing that engine will make Wscript a known identifier (variable) in any ASP script. You have to declare it and set it equal to a new object. The error you are getting makes sense since you haven't declared Wscript.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.