从IIS服务器上运行的VBS脚本(ASP) [英] Running VBS script on server from IIS (ASP)

查看:158
本文介绍了从IIS服务器上运行的VBS脚本(ASP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行一个ASP文件中的服务器上的一个VBS文件(IIS-6)
我已经改变了安全性因此一个必须登录到服务器访问ASP页面(这使ASP被获准所在的VBS文件存储的地方)。

I am trying to run a VBS file from within an ASP file on a server (IIS-6) I have changed the security so one have to login to the server to access the ASP-page (this so that ASP is given permission to the place where the VBS files are stored).

所以,我有一个Default.asp的页面看起来像这样:

So, I have a default.asp page that looks like this:

<%response.write "hello" 'just for debugging purposes.
set objshell = server.createobject("wscript.shell")
objShell.Run "c:\test\test.vbs",0,true '0=no interaction, true=wait for command to finish%>

VBS文件只是一个空文件(一些言论),所以会发生什么,是应该的WScript运行,什么都不做,关闭的wscript.exe并返回它完成。

The VBS file is just an empty file (some remarks) so what SHOULD happen, is the wscript should run, do nothing, close wscript.exe and return that it is done.

什么发生在上面的例子中是的wscript.exe启动服务器上,并且该网页等待命令完成。但从来没有退出的wscript.exe /自行停止。如果我结束的wscript.exe过程后,页面会继续加载。但是,VBS不会被执行。

What happens in the above example is that on the server wscript.exe starts, and the webpage waits for the command to finish. But the wscript.exe never quits/stops by itself. If I end the wscript.exe process then the page will continue loading. But the VBS will not have been executed.

所以,我已经尝试了一些修改,我加了code将VBS文件编写与执行时间的文件,所以我知道它不运行VBS文件。

So I have tried a few modifications, I added code to the VBS file to write a file with the time of the execution, so I KNOW that it does not run the VBS file.

我也曾尝试objshell.run/exec其他命令的变种:

I have also tried other variants of the objshell.run/exec commands:

objsshell.exec("cscript.exe /B /H:Cscript c:\test\test.vbs") ' nothing happens at all.
objsshell.exec("wscript.exe /B /H:Cscript c:\test\test.vbs") ' wscript and "hangs"

任何人有我如何得到VBS命令来运行任何提示和WScript.exe的进程退出?

Anyone have any tips on how I get the VBS command to run, and the Wscript.exe process to exit?

推荐答案

我想回答我的问题了几个摆弄了几个小时之后,因为我觉得我的发现将为比我更有趣。

I would like to answer my own question after a couple of hours of fiddling about, because I think my findings will be interesting for more than me.


  1. 要找出什么是在去服务去,选中了万维网服务与桌面交互。这样,所有的错误和msgboxes显示在控制台上。

通过编写以下小ASP的页面,我们得到一个控制台/ CMD窗口,使索姆测试用:

By writing the following small asp-page we got a console/cmd-window to make som tests with:

<%
set objshell=server.createobject("WScript.Shell")
objshell.run "cmd.exe"
%>

当你这样做伴随着与桌面交互你得到一个命令行窗口,如果你在这个窗口中写

When you do this along with "interact with desktop" you get a Commandline window and if you in this window write

echo %userprofile%

您获得正在运行CMD窗口用户。在我们的情况下,它是默认用户。

You get the user that is running the cmd-window. In our case it was "Default User".


  1. 在测试运行,我们发现VBS脚本默认用户剪掉有wscript.dll注册,我们不可能得到它要么登记。我们从来没有研究为什么。

  1. while testing to run vbs scripts we found that "Default user" didnt have the wscript.dll registered, and we couldnt get it to register either. We never got into why.

Cscript命令却没有需要注册,并且还与桌面互动少,因此较少的东西,可以停止脚本。我们还发现,你需要的完整路径的VBS文件要求的所有文件(这是很可能的一个大问题,因为我们有相对路径的工作)。

Cscript however did not need to be registered, and also had less interaction with the desktop, so less things that could stop the script. We also found that you need the FULL PATH to all files requested in the VBS file (this was probably one of the big issues, as we worked with relative paths).

所以经过了很多摆弄,最终ASP的code这样的作品,等待VBS脚本,以做它的东西,然后继续加载网页是:

So after a lot of fiddling, the final ASP-code that works, waits for the VBS-script to do its thing, then continues to load the page is:

<%
set objshell=server.createobject("WScript.Shell")
objshell.run "cmd.exe /c ""cscript c:\test\test.vbs " + request("any_parameters") + " Another_hardcoded_parameter""",1,true
set objshell=nothing
response.redirect("/a_new_page_with_info_from_vbs_file.asp")
%>

使用Windows集成身份验证或者设定访问这些文件作为其工作的网站匿名用户的用户,但也不是很安全的。

Use either windows integrated authentication or set a user with access to these files as the anonymous user for the website which works, but is not very safe.

这篇关于从IIS服务器上运行的VBS脚本(ASP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆