How to execute a bat file from a classic asp page

2019-01-26 10:15发布

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

2条回答
迷人小祖宗
2楼-- · 2019-01-26 10:55

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.

查看更多
神经病院院长
3楼-- · 2019-01-26 11:02

I finally make this to run changing IIS Application Pool defaults ( identity property ) from "ApplicationPoolIdentity" to "LocalSystem"

查看更多
登录 后发表回答