wscript.shell does not execute .vbs

A

AirYT

Done a bunch of searching on this topic and i have come up with nothing.

I have a .vbs script that i wish to execute by calling an asp page.

i am working on a W2K server with IIS5.0 & SP4.

My stopwebsite.vbs file is as follows:

===
On Error Resume Next
fullPath = "IIS://Localhost/W3svc/57"
Set oServer = GetObject(fullPath)
If Err <> 0 Then
Display "Unable to open " & fullPath & "."
End If
oServer.Stop
If Err <> 0 Then
Display "Unable to stop web server " & fullPath & "."
End If

Sub Display(Msg)
' WScript.Echo Now & ". Error Code: " & Hex(Err) & " - " & Msg
End Sub

===

NOTE that display doesn't do anything

my stopwebsite.asp script is as follows:
===
<%
On Error Resume Next
Set objScriptShell = Server.CreateObject("Wscript.Shell")
strCommand = "cscript.exe //b d:\inetpub\websites\admin\stopwebsite.vbs"
intReturn = objScriptShell.Run( strCommand )
response.write( "Command returned: " & intReturn )
Set objScriptShell = Nothing

if err.number <> 0 then
response.write "<hr>Error detected: " & err.number & ": " &
err.Description & "<br/>"
response.end
End if
%>
===

Normally i get that the command has executed successfully (ie. i get a 0
returned).
however the script doesn't actually run.

NOTE: i can run the command ("cscript.exe //b
d:\inetpub\websites\admin\stopwebsite.vbs") from a command line when logged
in as administrator successfully
I can also simply double click on the vbs (which i assume is executed by
wscript) from file explorer and it works successfully.

Things i have tried & applied:
the asp script is running on it's own virtual website with anonymous access
disabled. As such i am logging in as administrator when prompted.
i have tried different user permissions on the asp script & the vbs script.
at this point, everyone has full access to both scripts. this did not seem
to help.

any ideas??

thanks in advance.
yt

PS -- when i was locking down my server, i removed the built-in iis
administration website and probably the files that go with it. is there a
way to restore that without removing & reinstalling iis?
 
M

Mark J. McGinty

AirYT said:
Done a bunch of searching on this topic and i have come up with nothing.

I have a .vbs script that i wish to execute by calling an asp page.

i am working on a W2K server with IIS5.0 & SP4.

My stopwebsite.vbs file is as follows:

===
On Error Resume Next
fullPath = "IIS://Localhost/W3svc/57"
Set oServer = GetObject(fullPath)
If Err <> 0 Then
Display "Unable to open " & fullPath & "."
End If
oServer.Stop
If Err <> 0 Then
Display "Unable to stop web server " & fullPath & "."
End If

Sub Display(Msg)
' WScript.Echo Now & ". Error Code: " & Hex(Err) & " - " & Msg
End Sub


Why don't you just execute this script from ASP, i.e., replace the contents
of your stopwebsite.asp script, with what's in the .vbs file? That would be
a cut to the chase in my book. :)

I'm not sure specifically why what you have won't run, but my guess is that
it fails to create the WScript.Shell object. You should test Err.Number
immediately after a line you suspect may have caused the error, because
otherwise the Err object gets overwritten by the success of subsequent
lines.


-Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,044
Messages
2,570,388
Members
47,052
Latest member
ketan

Latest Threads

Top