Can I automate creating a .NET web application / virtual directory in IIS 5?

元气小坏坏 提交于 2019-12-17 19:26:40

问题


I asked this Can I automate creating a .NET web application in IIS? a little ago, and got solutions for IIS 6 and IIS 7:

  • IIS6 : iisweb /create C:\Rome "My Vacations" /d www.reskit.com /dontstart
  • IIS7 : %windir%\system32\inetsrv\AppCmd ADD SITE /name:MyNewSite /bindings:http/*:81: /physicalPath:c:\inetpub\mynewsite

but I've just got back to it the actual project, and it turns out that is I need to deploy on (shock-horror) IIS 5.1

Has anyone got any ideas?

To make it clear:

I want to use IIS, but I want to create the web application automatically (ideally batch file) without opening the IIS Microsoft Management Console (MMC)


回答1:


You can access the IIS 5.1 metabase in VBScript, and this allows you to create a virtual directory. For example, this should set up a Virtual Directory called 'TestDir' that points to the folder C:\inetpub\wwwroot\Test

strComputer = "localhost"
strVdirName = "TestDir"
strVdirPath = "C:\Inetpub\wwwroot\Test"

set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")
set objWebSite = objIIS.GetObject("IISWebVirtualDir","Root")
set objVdir = objWebSite.Create("IISWebVirtualDir",strVdirName)
objVdir.AccessRead = True
objVdir.Path = strVdirPath
objVdir.AppCreate (True)
objVdir.SetInfo
WScript.Echo "Successfully created virtual directory: " & objVdir.Name


来源:https://stackoverflow.com/questions/371207/can-i-automate-creating-a-net-web-application-virtual-directory-in-iis-5

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