General discussion

Locked

I could not run a batch file from my ASP page, help needed!

By bjhalfmanhalfamazing@yaho ·
Hi,

I have an ASP website that our group will use to gather info. When a visitor of the webpage enters data, the webpage creates a batch file on the server using user submitted data, and the batch file would run an executable on the server.

My problem is I can't get the batch file to run on the server. I have checked the server and it successfully creates a batch file. I have verified that the batch file did not run because the results of the batch file is not written on the server, but if I manually run (I'm logged in as administrator) the batch file, it creates results.

I have even tried to give IUSR with administrator priveleges just to check if it could execute the batch file on the server. But still it didn't work.

Here is the script:


Set TestJob = TxtFSO.CreateTextFile("C:\Inetpub\wwwroot\gather.bat")
TestJob.WriteLine "gather.exe -a -c"
TestJob.Close

Dim wshell, intReturn
set wshell = server.createobject("wscript.shell")
intReturn = wshell.run("C:\Inetpub\wwwroot\gather.bat", 0, True)
Response.Write( intReturn )
set wshell = nothing


Need help on this, guys!
I'm not really a web developer and I want to keep the webpage simple. I just want it to run the batch file.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Batch Files....

by Timothy J. Bruce In reply to I could not run a batch f ...

Ok, a couple of thoughts. NOTE: I'm not a web developer either...but I dabble a little in ASP.<br><br>

1. Don't use .BAT files. Use .CMD files. Why? Batch files run in a "shared" 16/32-bit environment (all these applications run in the same memory space and if any one in this environment crashes, everything crashes). A CMD file runs in a separate memory space, isolated from other applications. (And if I'm wrong I'm sure someone will chime in and add more detail! This is just what I've been told.)<br><br>

2. I don't think you can run a batch file (or command file) natively from inside IIS. I think you actually have to create a Command environment with something like the following:<br><br>
intReturn = wshell.run("%comspec% -c gather.cmd", 0, True)<br><br>

You'll also need to grant the IUSR_computer Account permissions to read/execute %comspec%.<br><br>

<b>NOTE:</b> This is extremely dangerous for anything that's public facing!<br><br>

YMMV.<br><br>

Tim

Collapse -

I agree with Timothy

by rclark In reply to I could not run a batch f ...

This is a very dangerous practice.

However, if you must do something like this, then use the website to write to your script file, then have a processor on the server input that as command strings and execute them one at a time. That way, your process can be much more robust, you can edit the data for validity, and you seperate the input from the execution. The only real reason for not doing it that way is if you have to have immediate execution of the script.

If that is the case, you can have the process be a server service that opens the input script, runs through it and deletes as it executes the script file.

Either way, you put a step between the input and the public with the ability to validate the script before you execute it.

Collapse -

Other Solutions

by rj In reply to I agree with Timothy

I would suggest using a separate Perl file to simply grab the info and pass it to the executable you need. Unless I misunderstand exactly what you are trying to do. This would be more secure and easier to do IMO. Tim is on the right road though about security and stability for your server. (I am a web developer)

Back to Networks Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums