Classic ASP - Running .exe from a Web Page on Localhost

半腔热情 提交于 2020-07-23 05:20:33

问题


I am trying to execute a .bat to launch notepad.exe on my localhost(server-side) with the following code:

index.asp

<%
set wshell = CreateObject("WScript.Shell") 
return = wshell.run("c:\file.bat", 4, false)
response.write(return)
set wshell = nothing 
%>

file.bat

notepad.exe

When I open the ASP page, nothing happens. A value 0 is returned because of the variable "return". So I tried set the false value to be true, and then the server froze and didn't return anything; I think that happened because there were no values to be returned from the .bat file. I tried also running the notepad.exe (C:\Windows\notepad.exe) directly instead of using a .bat file but still nothing happened. I also tried using ASPExec.dll but to no avail either.

Does anyone know what I am doing wrong?

More info:

My local web server is IIS7 that comes with Windows 7. I am doing this on localhost just for testing purposes. I have to accomplish this in Classic ASP because eventually I will have to import the website to a WinCE7 device. I am aware that WshShell is not available for WinCE but for now I am just trying to see if it works. Eventually I will need to be able to run a .exe that installs updates on the device through the website.


回答1:


Your code is running as a non-interactive IIS user; it cannot interact with the local desktop.



来源:https://stackoverflow.com/questions/7423294/classic-asp-running-exe-from-a-web-page-on-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!