Variable is undefined: 'Wscript'

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
LVL 1
jbrahyAsked:
Who is Participating?
 
thefritterfatboyCommented:
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
0
 
thefritterfatboyCommented:
ignore the first line of my response :p
0
 
inviserCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.