Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2847
  • Last Modified:

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
0
jbrahy
Asked:
jbrahy
  • 2
1 Solution
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now