asp能让bat文件运行吗??如何写代码,比如我有aa.bat文件,我如何编写asp就可以让这个bat运行??要代码!

来源:百度知道 编辑:UC知道 时间:2024/06/30 05:52:59
好像出问题了?你在试试!

服务器需要WScript.Shell支持,如果WScript.Shell被禁用了,就不能运行bat文件了.

给你个例子吧

准备a.txt文件,del.bat文件,del.asp文件

del.bat内容
del a.txt /f /s /q

del.asp文件内容
<%
Set WShShell = Server.CreateObject("WScript.Shell")
RetCode = WShShell.Run(server.mappath("del.bat"),1,True)
if RetCode = 0 Then
response.write "执行成功"
end If
%>

3个文件放到网站目录,访问del.asp后将执行del.bat的内容删除a.txt文件.