开发者

Run a vbscript under an IIS application

开发者 https://www.devze.com 2023-01-30 07:09 出处:网络
I have a vbs file that run开发者_如何学运维s fine and I want to run it under an IIS7 application name.Can this be done?If so, how?

I have a vbs file that run开发者_如何学运维s fine and I want to run it under an IIS7 application name. Can this be done? If so, how?

thanks


You could look under "Handler Mappings" in IIS and add one similar to ASP which is how I used to run VBScript on the server side years ago. This does imply that the file is on a web server and you are OK with HTML output of the result.


Just for fun, I was wondering how to do this. I found an article on the Microsoft support site which told me this was possible at one time. As of IIS 7.5 this is even easier than the article suggests. You simply need to create the mapping in IIS:

Run a vbscript under an IIS application

Steps

  1. Go to the IIS configuration and select the site you'd like to use VBS files with.

  2. Go to the Handler Mappings configuration for that site.

  3. Click Add Script Map... on the right hand side.

  4. Set the Request Path to *.vbs

  5. Set the Executable to "C:\Windows\System32\cscript.exe" //NOLOGO %s %s

  6. Set the Name to something you'll remember if you need to.

  7. Restart IIS (possibly optional but I did this)

Then, test it with a script such as the following:

WScript.Echo "Content-Type: text/html"
WScript.Echo
WScript.Echo "If you see this, it worked."

Save it as test.vbs in your site and go to the URL to see the results. Every script used this way must begin output with the first two lines of this script or IIS will not use it.

Note: I also have the CGI (from the Windows installation disk) and Fast-CGI (from the Windows download center) modules installed. I'm not sure whether either of these are actually needed though.

0

精彩评论

暂无评论...
验证码 换一张
取 消