如何从服务器上的经典asp页面执行bat文件 [英] How to execute a bat file from a classic asp page on the server
问题描述
我有一个简单的 bat 文件,它在执行时会运行访问宏,我需要知道如何从 asp 页面执行此 bat 文件,我已将所有权限授予包含脚本文件的特定文件夹的 iusr_machinename 和asp文件.
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.
谢谢
注意:我不想在客户端系统上运行任何东西,我只想在 asp 应用程序正在运行的同一系统上运行一个 bat 文件
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
推荐答案
假设您了解这样做的安全隐患,代码如下所示:
Assuming you understand the security implications of doing this, the code is as simple as:
set wshell = CreateObject("WScript.Shell")
wshell.run "c:path ofile.bat"
set wshell = nothing
我只是在一个虚拟实例上运行它,没有给 IUSR_* 任何特殊权限,它运行了一个 xcopy,没有错误或干扰.
I just ran this on a virtual instance without giving any special permissions to IUSR_* and it ran an xcopy without error or interference.
您将面临的另一个问题是当您的 BAT 文件引发提示或想要打开某种对话框时.处理输出确实很困难,因此在查看脚本的其他问题之前,请确保您的 BAT 文件运行无误.
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.
这篇关于如何从服务器上的经典asp页面执行bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!