Run a .bat with ASPExec

I'm working off Win2003 Server trying to execute a .bat file. It'd be nice to see the console output but not essential. I've downloaded and installed ASPExec from ServerObjects and have the following code that returns a 'ERROR: Could not create process':

<%
  Set Executor = Server.CreateObject("ASPExec.Execute")
  Executor.Application = "cmd"
  Executor.Parameters = "updatelog.bat"
  strResult = Executor.ExecuteDosApp
  Response.Write "<pre>" & strResult & "</pre>"
 %>


The batch file works if fired directly. IIS is set to execute Scripts & Executables. I've tried this with the IUSER having full perms with no difference in output. For giggles i even tried full perms on Everyone. No giggles and no joy.

Remember...Win2003 Server.

thankx
--steve...
juststeveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

juststeveAuthor Commented:
I've found a couple other questions dealing with ASPExec that have led me to correct the path for calling the bat:

<%
  Set Executor = Server.CreateObject("ASPExec.Execute")
  Executor.Application = "cmd"
  Executor.Parameters = "/c d:\web\Root\updatelog.bat"
  Executor.ShowWindow = false
  strResult = Executor.ExecuteDosApp
  Response.Write "<pre>" & strResult & "</pre>"
%>


This still gets me the same error so I replace:
  strResult = Executor.ExecuteDosApp
with:
  Executor.ExecuteDosApp

This does not produce an error but also does not run the batch.
0
TooKoolKrisCommented:
I think you need to tell the Application object to run the exe, like this:

Executor.Application = "cmd.exe"
0
TooKoolKrisCommented:
Oh, yea you can also do away with the parameters object and just put the whole command in the application object.

Executor.Application = "cmd /c d:\web\Root\updatelog.bat"
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

juststeveAuthor Commented:
No joy to either suggestion but something interesting.

Orginally I mentioned that I didn't get any error when I replace:
  strResult = Executor.ExecuteDosApp
with:
  Executor.ExecuteDosApp

I've discovered that this will not fire the error:
  strResult = Executor.ExecuteDosApp
if the line that attempts to write the value of the var is commented out:
'  Response.write (strResult)
0
TooKoolKrisCommented:
That's wierd, can't explain that other then to suggest that you double check to make sure there are no syntax errors anywhere. I don't see any in your code however. If you want to see the output to the console you can use a start /wait command to hold it open until your command is complete. For example if you wanted to watch all of your files being copied in the console window you would issue:

start /wait copy C:\test\*.* D:\test\

You can put the start /wait in from of any command you issue at a prompt. It's mostly used in batch files where you want each command to finish before the next one runs.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
juststeveAuthor Commented:
I'm betting it has something to do with IISv6.0...& am checking over in that area.
0
funkmailCommented:
Firstly, make sure you have given something like this

Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c c:\scripts\cards_mp.bat" //The script path
Executor.Parameters = "" //No need to specify anything
strResult = Executor.ExecuteDosApp

Then give full permission to IUSR & IWAM users on that particular directory.
Thats all required. But thats a security breach. What you can do is First try giving full permissions and then when it works remove the unwanted permissions like write etc.

Bye
S

0
funkmailCommented:
This would work for sure
0
juststeveAuthor Commented:
I have to drop the hunt for this particular solution but i think there's enough good information here to leave in the archives... and Kris deserves points for effort.
0
tleekCommented:
Hi,

I've had exactly the same problems with ASPEXEC on a new install of WinXP Pro. After burning the midnight oil, and tearing out most of my hair, I managed to get it working..

Thought I'd post a note with the things I did to fix it, in case any of these are useful to anyone.

checked 'Allow service to interact with desktop' for IIS Admin as well as WWW svcs
allowed IUSR_****** read access to cmd.exe and read/execute to target directory
turned _off_ script blocking in Norton AV 2003...

didn't need scripts and executables turned on, only scripts.

I need to set it up on a 2003 server tomorrow myself.

Tiff
0
tleekCommented:
Sorry, remembered the other thing that was messing things up.

.NET must be installed _after_ IIS for it all to function properly, you can just reinstall if nec.

(I think this is not supposed to apply to server 2003 though)

Tiff
0
gwilsonbCommented:
I tried CMD exec SSI includes and ServerObject's aspexec object but couldn't get either to work despite lots of trying. Perhaps both are difficult to get working after you've locked down IIS to make it more secure with something like Lockdown.

This worked however:

' show live server connections on an ASP page

dim ObjWshell, ObjCmd, strPResult
set ObjWshell = server.CreateObject("WScript.Shell")
set objCmd = objWShell.Exec("c:\utils\netstat -n")
strPResult = objCmd.StdOut.Readall()
Response.Write "<p><b>NetStat</b> Server Time: "& now
set objCmd = nothing
set ObjWshell = nothing
Response.Write "<font size=2>" & "<pre>" & 
      replace(strPResult,vbCRlf,"<br>") & "</pre>"

NB iusr_machinename (LOCAL machine a/c) MUST have RX permissions on the file you are calling (in this example I placed a copy of netstat in a directory and modified the permissions on it).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.