Run a vbscript under an IIS application
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:
Steps
Go to the IIS configuration and select the site you'd like to use VBS files with.
Go to the
Handler Mappings
configuration for that site.Click
Add Script Map...
on the right hand side.Set the
Request Path
to*.vbs
Set the
Executable
to"C:\Windows\System32\cscript.exe" //NOLOGO %s %s
Set the
Name
to something you'll remember if you need to.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.
精彩评论