Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a bat file from a classic asp page on the server

I have a simple bat file that runs an access macro when executed, i need to know how to execute this bat file from a asp page, i have given all the permissions to the iusr_machinename for that particular folder containing the script file and the asp file.

Thank you

Note: I don't want to run anything on the client system, i just want to run a bat file on the same system the asp application is running

like image 637
Vamsi Avatar asked Apr 13 '11 05:04

Vamsi


People also ask

How do I run a batch file on a server?

To run a batch file, move to the directory containing the file and type the name of the batch file. For example, if the batch file is named "hope. bat," you'd type "hope" to execute the batch file.

How do I run classic ASP files?

Click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then World Wide Web Services, then Application Development Features. Select ASP, and then click OK.

What is a bat executable?

A BAT file is known as a batch file runs with DOS and all versions of Windows, under cmd.exe. It consists of a series of line commands in plain text to be executed by the command-line interpreter to perform different tasks, such as running maintenance utilities within Windows or starting typical programs.


1 Answers

Assuming you understand the security implications of doing this, the code is as simple as:

set wshell = CreateObject("WScript.Shell") 
wshell.run "c:\path\to\file.bat" 
set wshell = nothing

I just ran this on a virtual instance without giving any special permissions to IUSR_* and it ran an xcopy without error or interference.

Another issue you will face is when your BAT file throws a prompt or wants to open some kind of dialog. It's really difficult to handle output, so make sure your BAT file runs without error before looking at further issues with the script.

Whether this code works in your environment is a matter of your security settings.

like image 129
Fred Wilson Avatar answered Oct 09 '22 15:10

Fred Wilson