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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a batch file with ASP 1

Status
Not open for further replies.

cglinn

Programmer
Sep 3, 2003
44
0
0
US
I am trying to run a batch file on the server through ASP. Below is my setup.

The batch file resides here:
C:\Batch Files\testbat.bat

It runs a couple executable files located in the same folder.

I have tried using Microsoft's Wscript.shell and the ASPExec free component.

I can get the batch process kicked off. However, the first executable shows up in the server's task manager but never completes and moves on to the next step in the batch file. It appears to just freeze. I can only imagine that it is some sort of permissions thing, but I have tried adding the IUSR account to the administrators group and the same thing happens. Any suggestions?

Thanks in advance!
 
i use some code to do what your asking for but ill be honest its a pain to setup :(. You need something called ASPExec which allows you to execute cmd line programs.

your gonna need access to your host server so you can set permissions.

here some example code for it:

SET Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /k c:\....\myfile.bat" Executor.Parameters = ""
strResult = Executor.ExecuteDosApp
Response.Write &quot;<p>&quot; & strResult & &quot;</p>&quot;

have to change some stuff on the server heres some notes i made when i set it up.

Start the Component services..in the tree select computers.. mycomputer..com+ applications...right click on it--> new -> application.. now in the wizard click next and select an empty application -> name your package leave it in server process and click next -> Select the user and enter an account with enough rights to fufill your com jobs (admin account for ex) -> Finish..

now in the tree expand the new package until you see the component directory-> right click it -> select new component-> in the wizard click next.. you can either install a new component if it's not registred or install a registred one if you already registred your dll (you select the 2nd choice) -> Select your component from the list (internal name displayed) -> Finish..

and voila..

also, I set the com+ guy up as userX, and I gave userX the anon user account on the IIS web site we used.


sorry if this doesnt make much sense, i spent a few hours looking on google for the solution i needed. A good place to start is to find a tutorial on ASPExec.
 
i use some code to do what your asking for but ill be honest its a pain to setup :(. You need something called ASPExec which allows you to execute cmd line programs.

your gonna need access to your host server so you can set permissions.

here some example code for it:

SET Executor = Server.CreateObject(&quot;ASPExec.Execute&quot;)
Executor.Application = &quot;cmd /k c:\....\myfile.bat&quot; Executor.Parameters = &quot;&quot;
strResult = Executor.ExecuteDosApp
Response.Write &quot;<p>&quot; & strResult & &quot;</p>&quot;

have to change some stuff on the server heres some notes i made when i set it up.

Start the Component services..in the tree select computers.. mycomputer..com+ applications...right click on it--> new -> application.. now in the wizard click next and select an empty application -> name your package leave it in server process and click next -> Select the user and enter an account with enough rights to fufill your com jobs (admin account for ex) -> Finish..

now in the tree expand the new package until you see the component directory-> right click it -> select new component-> in the wizard click next.. you can either install a new component if it's not registred or install a registred one if you already registred your dll (you select the 2nd choice) -> Select your component from the list (internal name displayed) -> Finish..

and voila..

also, I set the com+ guy up as userX, and I gave userX the anon user account on the IIS web site we used.


sorry if this doesnt make much sense, i spent a few hours looking on google for the solution i needed. A good place to start is to find a tutorial on ASPExec.


x2cms Website Builder - the fast and easy online sitebuilder
 
Thank you x2cms. I did a lot of web research and this is the first I have heard anything about having to create a new com+ object through component services. Anyone it worked and the batch file ran all the way through.

I appreciate such a descriptive post. Thank you.
 
I was able to get this working on a Windows 2000 Server with the instructions from x2cms. However, I now need to implement the same on a Windows NT Server.

The problem is that there doesn't appear to be a &quot;Component Services&quot; for Windows NT, I am assuming this was added in Win2k. Does anyone have a way around this? Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top