Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASPExec Not Running Batch File

Status
Not open for further replies.

thankgodfortektips

Programmer
Dec 20, 2005
95
KY
Hi All,

I have been banging my head against the wall with this for ages... below is the code that I am trying to run. As you can see it 'should' be very simple.

The batch file that it runs only has one simple line (for now)... mkdir c:\temp\hello

The page will reply with an Ok message, but the batch file is not actually running. I have given the Internet Guest Account full permission to c:\windows\system32 and c:\temp... but still no look.

Thanks in advance!


<html>
<head><title>ASPExec Test (copy)</title><head>
<body>
<H3>ASPExec Copy Test</H3>

<%
Dim SiteToMake
sitetomake = "c:\temp\test.bat"' & chr(34)
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c " & SiteToMake
Executor.Parameters = ""
strResult = Executor.ExecuteWinApp
Response.Write "<pre>" & strResult & "</pre>"
%>

</body>

</html>
 
do you get an error?

is this a typo in the posting or no?
sitetomake = "c:\temp\test.bat"'<-- typo & chr(34)

 
sorry that is not a typo, i tried passing it with chr(34)
at the front and back, just to make sure.

it is commented out though, so it doesn't affect the code.
 
I would try a echo to see if it is a permissions problem which it sounds like

 
[tt]>Executor.Application = "cmd /c " & SiteToMake
>Executor.Parameters = ""
[/tt]
[tt]
Executor.Application = "cmd"
Executor.Parameters = "/c " & SiteToMake"
[/tt]
 
Take out the last leftover quote. A relist...
[tt]
Executor.Application = "cmd"
Executor.Parameters = "/c " & SiteToMake
[/tt]
 
nope, still didn't work... I change the code to not use the variable as well...
**********************
Executor.Application = "cmd c:\temp\test.bat"
**********************

The code is definitely working because when I use the following...
**********************
<%
Dim SiteToMake
sitetomake = "notepad"
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c " & SiteToMake
Executor.Parameters = ""
strResult = Executor.ExecuteWinApp
Response.Write "<pre>" & strResult & "</pre>"
%>
**********************
I see notepad open in the processes list... but when I try running a batch file... nothing happens.

HEELLPPPP!!!!!

thanks again!
 
Put the bat in the same directory as your notepad then use your version or mine. If it runs, it might well be the permission-related problem on accessing the temp directory.

Also why you write this line.
>[tt]Executor.Application = "cmd c:\temp\test.bat"[/tt]

Is it just a typos? You _must_ have the switch /c (or /k but not in this case) for a command line of the kind.
[tt]Executor.Application = "cmd [red]/c[/red] c:\temp\test.bat"[/tt]

 
I could swear I posted to this one the other day, but I'm not seeing it now.

Take a look at the ASPCOPY.asp and ASPDIR.asp example. They are both using the .ExecuteDosApp method. I originally thought that you would need to move all of the parameters from the .Application property to the .Parameters property, but the ASPCOPY example shows them all in the .Applcation property, so that must be acceptable.

This section of the ASPExec file that came with your download may be useful as well:
ASPExec.txt said:
ExecuteDosApp : Executes the specified app as a DOS app and returns
stdio as string
ExecuteWinAppAndWait : Execute the specified app as a Windows app and wait
for the specified timeout if exec is successful
ExecuteWinApp : Execute the specified app as a Windows app and return
result code immediately

barcode_1.gif
 
I have took a look at all pages that come with ASPExec, and cant get any of them to run... I have even tried the below code, and it doesn't work.

**************************
set wshell = CreateObject("WScript.Shell")
wshell.run "%COMSPEC% /C c:\temp\test.bat"
set wshell = nothing
**************************

Again, this will open notepad, but cant run the batch file.

Is there a way to make the batch file into an executable and pass variables to it? This would solve my issue as the code I currently have seems to be able to run exe...

Thanks for all the help guys!
 
Are you on windows xp or 2003? I have run into an issue in the past with cmd.exe needing permissions alterations (namely, the addition of permissions for the default web user) before it could be executed. Granted, that was from PHP, but might be a similar situation.

barcode_1.gif
 
windows 2003, I have given the iuser_machinename full permission to the system32, the directy were the batch file is... but it still doesn't run.

 
>windows 2003, I have given the iuser_machinename full permission to the system32

Would it help if you add it to the file permissions list on the cmd.exe itself as well? (It seems w2k3 might need to be this specific.)
 
As suggested above, have you tried moving the BAT file to the same folder your script is executing in?
That tells you if it is a script or permissions problem.

I think that to allow your script to execute outside of the IIS folders you need to set permissions for the IWAM_machinename account rather than the IUSR_machinename account.

I am not familiar with ASPExec but does it really require that you execute CMD? Does it not already use the shell to execute files directly? I would think you could just directly execute the .bat file.

I have done similar things but by using the shell object to execute the file rather than using an add-on like ASPExec.



Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top