473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Anyone know how to execute a Windows Script from ASP?

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
14 5827
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Skip Montanaro | last post by:
I wrote PEP 304, "Controlling Generation of Bytecode Files": http://www.python.org/peps/pep-0304.html quite awhile ago. The first version appeared in January 2003 in response to questions...
1
by: Matt | last post by:
I used to execute a command line script in IIS 4 using Dynuexec. This is a third part server object I installed on the server (http://www.dynu.com/dynuexec.asp). I installed this object onto my...
4
by: Ersin Gençtürk | last post by:
Server : WEB System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.Web.HttpException: The View State is invalid for this page and might be...
14
by: technocrat | last post by:
db2 -t -v -f/home.../filename >output_file-name I have a java stored procedure..which has to run the above command...not sure how i can run this command through java.. any suggestions are...
1
by: MPutt | last post by:
I apologize if I am posting this to the wrong area, but I am stuck. Here is my problem. I am running a .NET 2003 Windows service against Oracle 9i. This service is attempting to run a stored...
7
by: spec | last post by:
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? ...
8
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this...
3
by: joe jacob | last post by:
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added <Directory...
2
by: rcook349 | last post by:
I'm trying to automate our builds and publishes of our Windows application (deployed to a website via ClickOnce). I'm getting close, I think, on the commands I need to execute. However, how do...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.