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

Re: Anyone know how to execute a Windows Script from ASP? by Ken

Ken
Mon Sep 15 21:09:48 CDT 2003

WScript.Shell?

Cheers
Ken


"Larry Woods" <larry@lwoods.com> wrote in message
news:epfpMU%23eDHA.1056@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
:
:



Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Mon Sep 15 22:20:04 CDT 2003

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" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:%23SDZce$eDHA.2172@TK2MSFTNGP09.phx.gbl...
> WScript.Shell?
>
> Cheers
> Ken
>
>
> "Larry Woods" <larry@lwoods.com> wrote in message
> news:epfpMU%23eDHA.1056@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
> :
> :
>
>



Re: Anyone know how to execute a Windows Script from ASP? by Ken

Ken
Mon Sep 15 23:45:18 CDT 2003

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" <larry@lwoods.com> wrote in message
news:uuu0GGAfDHA.2400@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
: news:%23SDZce$eDHA.2172@TK2MSFTNGP09.phx.gbl...
: > WScript.Shell?
: >
: > Cheers
: > Ken
: >
: >
: > "Larry Woods" <larry@lwoods.com> wrote in message
: > news:epfpMU%23eDHA.1056@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
: > :
: > :
: >
: >
:
:



Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Tue Sep 16 00:13:04 CDT 2003

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" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:O1n2V1AfDHA.1712@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" <larry@lwoods.com> wrote in message
> news:uuu0GGAfDHA.2400@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> : news:%23SDZce$eDHA.2172@TK2MSFTNGP09.phx.gbl...
> : > WScript.Shell?
> : >
> : > Cheers
> : > Ken
> : >
> : >
> : > "Larry Woods" <larry@lwoods.com> wrote in message
> : > news:epfpMU%23eDHA.1056@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
> : > :
> : > :
> : >
> : >
> :
> :
>
>



Re: Anyone know how to execute a Windows Script from ASP? by Ken

Ken
Tue Sep 16 00:18:25 CDT 2003

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" <larry@lwoods.com> wrote in message
news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
: news:O1n2V1AfDHA.1712@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
: >
:



RE: Anyone know how to execute a Windows Script from ASP? by lukezhan

lukezhan
Tue Sep 16 00:23:07 CDT 2003

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.)


Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Tue Sep 16 06:11:44 CDT 2003

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" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:%23Aau1HBfDHA.4024@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" <larry@lwoods.com> wrote in message
> news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> : news:O1n2V1AfDHA.1712@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
> : >
> :
>
>



Re: Anyone know how to execute a Windows Script from ASP? by Bob

Bob
Tue Sep 16 06:43:35 CDT 2003

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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> news:%23Aau1HBfDHA.4024@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" <larry@lwoods.com> wrote in message
>> news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
>>> news:O1n2V1AfDHA.1712@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




Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Tue Sep 16 08:34:33 CDT 2003

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

Larry

"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:eRSIDfEfDHA.2248@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> > news:%23Aau1HBfDHA.4024@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" <larry@lwoods.com> wrote in message
> >> news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> >>> news:O1n2V1AfDHA.1712@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
>
>
>



Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Tue Sep 16 08:35:25 CDT 2003

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" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:%23Aau1HBfDHA.4024@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" <larry@lwoods.com> wrote in message
> news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> : news:O1n2V1AfDHA.1712@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
> : >
> :
>
>



Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Tue Sep 16 11:12:37 CDT 2003

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

Larry Woods

"MSFT" <lukezhan@online.microsoft.com> wrote in message
news:avfMfKBfDHA.3192@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.)
>



Re: Anyone know how to execute a Windows Script from ASP? by Ken

Ken
Tue Sep 16 20:38:29 CDT 2003

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" <larry@lwoods.com> wrote in message
news:u1ny9dFfDHA.1872@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
: news:%23Aau1HBfDHA.4024@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" <larry@lwoods.com> wrote in message
: > news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
: > : news:O1n2V1AfDHA.1712@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
: > : >
: > :
: >
: >
:
:



Re: Anyone know how to execute a Windows Script from ASP? by Larry

Larry
Tue Sep 16 21:19:14 CDT 2003

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" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:OJs8mxLfDHA.3216@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" <larry@lwoods.com> wrote in message
> news:u1ny9dFfDHA.1872@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> : news:%23Aau1HBfDHA.4024@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" <larry@lwoods.com> wrote in message
> : > news:ehW9PFBfDHA.3076@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" <kenREMOVE@THISadOpenStatic.com> wrote in message
> : > : news:O1n2V1AfDHA.1712@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
> : > : >
> : > :
> : >
> : >
> :
> :
>
>



Re: Anyone know how to execute a Windows Script from ASP? by lukezhan

lukezhan
Wed Sep 17 02:55:38 CDT 2003

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.)