经典 ASP - 从本地主机上的网页运行 .exe
我正在尝试执行 .bat 以使用以下代码在本地主机(服务器端)上启动 notepad.exe:
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
当我打开 ASP 页面时,没有任何反应。由于变量“return”,返回值 0。所以我尝试将 false 值设置为 true,然后服务器冻结并且没有返回任何内容;我认为发生这种情况是因为 .bat 文件没有返回任何值。 我还尝试直接运行 notepad.exe (C:\Windows\notepad.exe),而不是使用 .bat 文件,但仍然没有任何反应。我也尝试使用 ASPExec.dll 但也无济于事。
有谁知道我做错了什么?
更多信息:
我的本地 Web 服务器是 Windows 7 附带的 IIS7。我在本地主机上执行此操作只是为了测试目的。我必须在经典 ASP 中完成此操作,因为最终我必须将网站导入到 WinCE7 设备。我知道 WshShell 不适用于 WinCE,但现在我只是想看看它是否有效。最终,我需要能够运行 .exe,通过网站在设备上安装更新。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码以非交互式 IIS 用户身份运行;它无法与本地桌面交互。
Your code is running as a non-interactive IIS user; it cannot interact with the local desktop.