[英]change physical path for virtual directory or site in IIS using command line for IIs6 or IIs7
I need to implement some versioning for deployment for the app I support where I can copy the site to say c:\inetpub\wwwroot\app_v2 and then switch the virtual directory from c:\inetpub\wwwroot\app_v1.我需要为我支持的应用程序部署一些版本控制,我可以将站点复制到 c:\inetpub\wwwroot\app_v2,然后从 c:\inetpub\wwwroot\app_v1 切换虚拟目录。
Is there a way to change the physical path for a virtual directory in IIS from the command line?有没有办法从命令行更改 IIS 中虚拟目录的物理路径?
Edit:编辑:
i found that in IIS7 you can use appcmd to set the physical path of a virtual directory using this format on this page Change the Physical Path of Virtual Directory Content .我发现在 IIS7 中,您可以使用 appcmd 在此页面上使用此格式设置虚拟目录的物理路径 Change the Physical Path of Virtual Directory Content 。 I was looking for something more universal....
我一直在寻找更普遍的东西......
appcmd set vdir /vdir.name:string /physicalPath:string appcmd 设置 vdir /vdir.name:string /physicalPath:string
However, there doesnt seem to be an equivelant for IIS 6.但是,似乎没有 IIS 6 的等价物。
Yes, look at WMI scripting.是的,看看 WMI 脚本。
http://learn.iis.net/page.aspx/163/managing-applications-and-application-pools-on-iis-7-with-wmi/ http://learn.iis.net/page.aspx/163/managing-applications-and-application-pools-on-iis-7-with-wmi/
http://www.aspfree.com/c/a/IIS/IIS-60-Getting-Information-Using-WMI/3/ http://www.aspfree.com/c/a/IIS/IIS-60-Getting-Information-Using-WMI/3/
Nick缺口
I had the same question today: "how do you change the path to an IIS6 vdir using the command line?"我今天也有同样的问题:“如何使用命令行更改 IIS6 vdir 的路径?”
WMI scripting was the way to go, so i figured i'd post the vbs that i created for this. WMI 脚本是通往 go 的方式,所以我想我会发布为此创建的 vb。
To use it just pass the vdir name and path.要使用它,只需传递 vdir 名称和路径。 So if I had a vdir called "Web" and wanted to change the path to "d:\theNewPath\to\Website", then I would run the following command in the command prompt:
因此,如果我有一个名为“Web”的 vdir 并想将路径更改为“d:\theNewPath\to\Website”,那么我将在命令提示符下运行以下命令:
updateVDirPath web d:\theNewPath\to\Website
Also, to check the path of the Vdir, just pass the vdir name:此外,要检查 Vdir 的路径,只需传递 vdir 名称:
updateVDirPath web
Here are the contents to updateVDirPath.vbs这里是updateVDirPath.vbs的内容
If WScript.Arguments.Count = 0 or WScript.Arguments.Count > 2 Then
WScript.Echo "To check the vDirs path, call updateVDirPath <vDir>" & vbCrLf & "To update the vDir's path, call updateVDirPath <vDir> <newPath>"
Else
set providerObj = GetObject("winmgmts://localhost/root/MicrosoftIISv2")
set IIsWebVirtualDirSettingObj = providerObj.get("IIsWebVirtualDirSetting='W3SVC/1/ROOT/" & WScript.Arguments(0) & "'")
If WScript.Arguments.Count = 1 Then
WScript.Echo "Current path is: " & IIsWebVirtualDirSettingObj.Path
Else
IIsWebVirtualDirSettingObj.Path = WScript.Arguments(1)
IIsWebVirtualDirSettingObj.Put_ ()
End If
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.