asp 使用aspexec组件执行 exe

http://hi.baidu.com/kk126/blog/item/e44b6b27afc50407918f9d17.html
http://www.ly705.cn/blog/archives/20071228/93.html
http://www.lilu.name/Html/diannaojishu/2008-7/962025.html

aspexe.dll文件是一个能调用asp文件执行服务器端程序的组件,使用非常方便。当然在调用服务端程序还可以通过server.createobject("wscript.shell")来完成,不过这个不太好用。


首先给大家提供下载:[点击浏览该文件:ASPEXEC.DLL]


现在将aspexec.dll的语法或者说是用法介绍如下:


1.首先在系统中注册该组件。下载该dll文件后放在系统system32目录中,然后在“运行”中输入:regsvr32 aspexec.dll,应该就会出现提示注册组件成功!


2.首先建立一个对象
set aspexe=server.createobject("aspexec.execute")


3.指定要运行的应用程序的名称和路径
aspexe.application="notepad.exe"


4.设定运行的程序的参数
aspexe.parameters="c:\autoexec.bat"


5.指定超时时间
aspexe.timeout=60000  (ms)


6.设定运行程序运行时是否显示视窗
aspexe.showwindow=true


7.根据不同的程序类型,调用不同的运行方式
====此方式执行DOS程序,然后返回一个字符串作为结果====
aspexe.ExecuteDosApp


====此方式执行windows程序,如果程序运行成功还会等待指定的timeout的时间====
aspexe.ExecuteWinAppAndWait


====此方式执行windows程序,并且立刻返回结果代码====
aspexe.ExecuteWinApp


下面给出一个使用例子:


dim aspexe,strResult
set aspexe=server.createobject("aspexec.execute")
aspexe.application="notepad.exe"
aspexe.parameters="c:\autoexec.bat"
aspexe.timeout=60000
aspexe.showwindow=true
response.write("尝试运行程序:"&aspexe.application&"<br>")
strResult=aspexe.ExecuteWinApp
response.write("程序运行的结果是:"&strResult)


如果程序能正常运行,在页面上显示的结果应该是:


尝试运行程序:notepad.exe
运行的结果是:Ok


如果出现的不是OK结果,出现如下结果,就是权限设置的问题。


服务器对象 错误 'ASP 0178 : 80070005'


Server.CreateObject 访问错误


/aspexec.asp,行14


检查权限时Server.CreateObject 的调用失败。对此对象的访问被拒。


解决办法就是到system32目录中,给aspexec.dll文件IUSR_用户读取和写入权限 就可以了。


下面是一段调用程序的实例代码

<%@ Language = "VBScript" %>
<% Response.Buffer = false %>
<%
dim aspexe,strResult
set aspexe  = server.createObject("aspexec.execute")
aspexe.application = "C:\Inetpub\wwwroot\bpmdetect\bpmdetect.exe"
aspexe.parameters = "C:\Inetpub\wwwroot\bpmdetect\1.mp3"
aspexe.showwindow = true
response.write("尝试运行程序:"&aspexe.application&"<br>")
strResult = aspexe.ExecuteDosApp
response.write(strResult)
dim result
result = split(strResult," ")
response.write("程序运行的结果是:"&result(ubound(result)-1))

%>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值