By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

Anyone know how to execute a Windows Script from ASP?

P: n/a
I need to execute a Windows script (wscript/cscript) from an ASP page for
some administrative functions. Anyone doing this? If so, how?

TIA,

Larry Woods
Jul 19 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
WScript.Shell?

Cheers
Ken
"Larry Woods" <la***@lwoods.com> wrote in message
news:ep****************@TK2MSFTNGP10.phx.gbl...
: I need to execute a Windows script (wscript/cscript) from an ASP page for
: some administrative functions. Anyone doing this? If so, how?
:
: TIA,
:
: Larry Woods
:
:
Jul 19 '05 #2

P: n/a
Have you ever done it? I have tried using WScipt.Shell in about every way
that I know how and it doesn't execute the script. If you have an example I
would appreciate seeing it.

Thanks

Larry Woods

"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
WScript.Shell?

Cheers
Ken
"Larry Woods" <la***@lwoods.com> wrote in message
news:ep****************@TK2MSFTNGP10.phx.gbl...
: I need to execute a Windows script (wscript/cscript) from an ASP page for : some administrative functions. Anyone doing this? If so, how?
:
: TIA,
:
: Larry Woods
:
:

Jul 19 '05 #3

P: n/a
There are lots of sample scripts on the web. When you say "it doesn't
work" - what do you mean? Do you get an error? (the number 1 problem I see
is permissions problems)

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:uu**************@TK2MSFTNGP11.phx.gbl...
: Have you ever done it? I have tried using WScipt.Shell in about every way
: that I know how and it doesn't execute the script. If you have an example
I
: would appreciate seeing it.
:
: Thanks
:
: Larry Woods
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:%2****************@TK2MSFTNGP09.phx.gbl...
: > WScript.Shell?
: >
: > Cheers
: > Ken
: >
: >
: > "Larry Woods" <la***@lwoods.com> wrote in message
: > news:ep****************@TK2MSFTNGP10.phx.gbl...
: > : I need to execute a Windows script (wscript/cscript) from an ASP page
: for
: > : some administrative functions. Anyone doing this? If so, how?
: > :
: > : TIA,
: > :
: > : Larry Woods
: > :
: > :
: >
: >
:
:
Jul 19 '05 #4

P: n/a
I get no indication that the script worked. The script is supposed to
create a small text file. The file ain't there! When I execute the script
from the command line it works fine.
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
There are lots of sample scripts on the web. When you say "it doesn't
work" - what do you mean? Do you get an error? (the number 1 problem I see
is permissions problems)

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:uu**************@TK2MSFTNGP11.phx.gbl...
: Have you ever done it? I have tried using WScipt.Shell in about every way : that I know how and it doesn't execute the script. If you have an example I
: would appreciate seeing it.
:
: Thanks
:
: Larry Woods
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:%2****************@TK2MSFTNGP09.phx.gbl...
: > WScript.Shell?
: >
: > Cheers
: > Ken
: >
: >
: > "Larry Woods" <la***@lwoods.com> wrote in message
: > news:ep****************@TK2MSFTNGP10.phx.gbl...
: > : I need to execute a Windows script (wscript/cscript) from an ASP page : for
: > : some administrative functions. Anyone doing this? If so, how?
: > :
: > : TIA,
: > :
: > : Larry Woods
: > :
: > :
: >
: >
:
:

Jul 19 '05 #5

P: n/a
Do you have On Error Resume Next in your ASP page?

Also, when you talk about a script - I assume you don't mean a .bat batch
file, but rather a .vbs WScript file (or similar)?

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
: I get no indication that the script worked. The script is supposed to
: create a small text file. The file ain't there! When I execute the
script
: from the command line it works fine.
:
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:O1**************@TK2MSFTNGP11.phx.gbl...
: > There are lots of sample scripts on the web. When you say "it doesn't
: > work" - what do you mean? Do you get an error? (the number 1 problem I
see
: > is permissions problems)
: >
: > Cheers
: > Ken
: >
:
Jul 19 '05 #6

P: n/a
Hi Larry,

Did you want to execute a VBS file or some VB Script code? On client side
or server side?

Luke
Microsoft Online Partner Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 19 '05 #7

P: n/a
I'm talking about a .vbs WScript.

Here is the ASP Page ( in wwwroot ):

<% dim s

s=Server.MapPath("listprocesses.vbs")
CommandLine s,""

Sub CommandLine(progName,strVariable)
'Create Shell Object
Set objScriptShell = Server.CreateObject("Wscript.Shell")
'now run your program and dump the results into a .txt file
ss= "cscript " & progName & " " & strVariable _
& "> " & Server.MapPath("shellLog") & "\log" & ".txt"

objScriptShell.Run (ss, 0, True)
End Sub

And here is the vbs script that I am trying to execute ( in wwwroot ):

'
' listprocesses.vbs
'
set objService = getobject("winmgmts:")
dim s
for each Process in objService.InstancesOf("Win32_process")
if lcase(process.name)="dllhost.exe" then
s=s & Process.Name & vbTab & Process.processid & vbCrLf
end if
Next
WScript.echo s

TIA,

Larry
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Do you have On Error Resume Next in your ASP page?

Also, when you talk about a script - I assume you don't mean a .bat batch
file, but rather a .vbs WScript file (or similar)?

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
: I get no indication that the script worked. The script is supposed to
: create a small text file. The file ain't there! When I execute the
script
: from the command line it works fine.
:
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:O1**************@TK2MSFTNGP11.phx.gbl...
: > There are lots of sample scripts on the web. When you say "it doesn't
: > work" - what do you mean? Do you get an error? (the number 1 problem I
see
: > is permissions problems)
: >
: > Cheers
: > Ken
: >
:

Jul 19 '05 #8

P: n/a
Could this be the problem? Given that you've already checked Permissions,
that is:
http://www.aspfaq.com/show.asp?id=2180

Bob Barrows

Larry Woods wrote:
I'm talking about a .vbs WScript.

Here is the ASP Page ( in wwwroot ):

<% dim s

s=Server.MapPath("listprocesses.vbs")
CommandLine s,""

Sub CommandLine(progName,strVariable)
'Create Shell Object
Set objScriptShell = Server.CreateObject("Wscript.Shell")
'now run your program and dump the results into a .txt file
ss= "cscript " & progName & " " & strVariable _
& "> " & Server.MapPath("shellLog") & "\log" & ".txt"

objScriptShell.Run (ss, 0, True)
End Sub

And here is the vbs script that I am trying to execute ( in wwwroot ):

'
' listprocesses.vbs
'
set objService = getobject("winmgmts:")
dim s
for each Process in objService.InstancesOf("Win32_process")
if lcase(process.name)="dllhost.exe" then
s=s & Process.Name & vbTab & Process.processid & vbCrLf
end if
Next
WScript.echo s

TIA,

Larry
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Do you have On Error Resume Next in your ASP page?

Also, when you talk about a script - I assume you don't mean a .bat
batch file, but rather a .vbs WScript file (or similar)?

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
I get no indication that the script worked. The script is supposed
to create a small text file. The file ain't there! When I execute
the script from the command line it works fine.
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
There are lots of sample scripts on the web. When you say "it
doesn't work" - what do you mean? Do you get an error? (the number
1 problem I see is permissions problems)

Cheers
Ken


Jul 19 '05 #9

P: n/a
Thanks, Bob, but I am not running Norton, etc. on this server so it can't be
the "culprit".

Larry

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl...
Could this be the problem? Given that you've already checked Permissions,
that is:
http://www.aspfaq.com/show.asp?id=2180

Bob Barrows

Larry Woods wrote:
I'm talking about a .vbs WScript.

Here is the ASP Page ( in wwwroot ):

<% dim s

s=Server.MapPath("listprocesses.vbs")
CommandLine s,""

Sub CommandLine(progName,strVariable)
'Create Shell Object
Set objScriptShell = Server.CreateObject("Wscript.Shell")
'now run your program and dump the results into a .txt file
ss= "cscript " & progName & " " & strVariable _
& "> " & Server.MapPath("shellLog") & "\log" & ".txt"

objScriptShell.Run (ss, 0, True)
End Sub

And here is the vbs script that I am trying to execute ( in wwwroot ):

'
' listprocesses.vbs
'
set objService = getobject("winmgmts:")
dim s
for each Process in objService.InstancesOf("Win32_process")
if lcase(process.name)="dllhost.exe" then
s=s & Process.Name & vbTab & Process.processid & vbCrLf
end if
Next
WScript.echo s

TIA,

Larry
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Do you have On Error Resume Next in your ASP page?

Also, when you talk about a script - I assume you don't mean a .bat
batch file, but rather a .vbs WScript file (or similar)?

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
I get no indication that the script worked. The script is supposed
to create a small text file. The file ain't there! When I execute
the script from the command line it works fine.
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
> There are lots of sample scripts on the web. When you say "it
> doesn't work" - what do you mean? Do you get an error? (the number
> 1 problem I see is permissions problems)
>
> Cheers
> Ken


Jul 19 '05 #10

P: n/a
Ken,

Additional information:

I am getting a return code of "1" from the Run method--but can't find any MS
doc that tells me what that means.

Larry

"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Do you have On Error Resume Next in your ASP page?

Also, when you talk about a script - I assume you don't mean a .bat batch
file, but rather a .vbs WScript file (or similar)?

Cheers
Ken

"Larry Woods" <la***@lwoods.com> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
: I get no indication that the script worked. The script is supposed to
: create a small text file. The file ain't there! When I execute the
script
: from the command line it works fine.
:
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:O1**************@TK2MSFTNGP11.phx.gbl...
: > There are lots of sample scripts on the web. When you say "it doesn't
: > work" - what do you mean? Do you get an error? (the number 1 problem I
see
: > is permissions problems)
: >
: > Cheers
: > Ken
: >
:

Jul 19 '05 #11

P: n/a
I want to execute a .vbs file on the server. I want to execute it from an
ASP page.

Larry Woods

"MSFT" <lu******@online.microsoft.com> wrote in message
news:av**************@cpmsftngxa07.phx.gbl...
Hi Larry,

Did you want to execute a VBS file or some VB Script code? On client side
or server side?

Luke
Microsoft Online Partner Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 19 '05 #12

P: n/a
That's an "error". Possible return codes are (if I'm looking at the right
info):

0 SUCCESS
1 ERROR
2 WARNING
4 INFORMATION
8 AUDIT_SUCCESS
16 AUDIT_FAILURE
Looking at the script you are running - I suspect that IUSR_<machinename>
wouldn't be able to enumerate a list of running processes (if it is in the
Guests group) - but I'm not sure about that.

Can you turn off "Allow Anonymous Access", and authenticate as a local
administrator, and see if your script runs?

Cheers
Ken
"Larry Woods" <la***@lwoods.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
: Ken,
:
: Additional information:
:
: I am getting a return code of "1" from the Run method--but can't find any
MS
: doc that tells me what that means.
:
: Larry
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:%2****************@TK2MSFTNGP11.phx.gbl...
: > Do you have On Error Resume Next in your ASP page?
: >
: > Also, when you talk about a script - I assume you don't mean a .bat
batch
: > file, but rather a .vbs WScript file (or similar)?
: >
: > Cheers
: > Ken
: >
: > "Larry Woods" <la***@lwoods.com> wrote in message
: > news:eh**************@tk2msftngp13.phx.gbl...
: > : I get no indication that the script worked. The script is supposed to
: > : create a small text file. The file ain't there! When I execute the
: > script
: > : from the command line it works fine.
: > :
: > :
: > : "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: > : news:O1**************@TK2MSFTNGP11.phx.gbl...
: > : > There are lots of sample scripts on the web. When you say "it
doesn't
: > : > work" - what do you mean? Do you get an error? (the number 1 problem
I
: > see
: > : > is permissions problems)
: > : >
: > : > Cheers
: > : > Ken
: > : >
: > :
: >
: >
:
:
Jul 19 '05 #13

P: n/a
I think that it is something much more basic, Ken. I commented ALL of the
lines of the script and I am still getting the return code of 1. I checked
the script and all permissions are turned on ("Full Control"). Also inetpub
and wwwroot. I can't figure out what I am missing.

Larry

"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
That's an "error". Possible return codes are (if I'm looking at the right
info):

0 SUCCESS
1 ERROR
2 WARNING
4 INFORMATION
8 AUDIT_SUCCESS
16 AUDIT_FAILURE
Looking at the script you are running - I suspect that IUSR_<machinename>
wouldn't be able to enumerate a list of running processes (if it is in the
Guests group) - but I'm not sure about that.

Can you turn off "Allow Anonymous Access", and authenticate as a local
administrator, and see if your script runs?

Cheers
Ken
"Larry Woods" <la***@lwoods.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
: Ken,
:
: Additional information:
:
: I am getting a return code of "1" from the Run method--but can't find any MS
: doc that tells me what that means.
:
: Larry
:
: "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: news:%2****************@TK2MSFTNGP11.phx.gbl...
: > Do you have On Error Resume Next in your ASP page?
: >
: > Also, when you talk about a script - I assume you don't mean a .bat
batch
: > file, but rather a .vbs WScript file (or similar)?
: >
: > Cheers
: > Ken
: >
: > "Larry Woods" <la***@lwoods.com> wrote in message
: > news:eh**************@tk2msftngp13.phx.gbl...
: > : I get no indication that the script worked. The script is supposed to : > : create a small text file. The file ain't there! When I execute the
: > script
: > : from the command line it works fine.
: > :
: > :
: > : "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: > : news:O1**************@TK2MSFTNGP11.phx.gbl...
: > : > There are lots of sample scripts on the web. When you say "it
doesn't
: > : > work" - what do you mean? Do you get an error? (the number 1 problem I
: > see
: > : > is permissions problems)
: > : >
: > : > Cheers
: > : > Ken
: > : >
: > :
: >
: >
:
:

Jul 19 '05 #14

P: n/a
Hi Larry,

I found "WScript.Echo" in your VBS code, this method will outputs text to
either a message box or the command console window. However, you can't do
this in ASP server side. You may use LogEvent method instead.
Luke
Microsoft Online Partner Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 19 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.