简体   繁体   English

从命令行获取IIS Express物理路径

[英]Get IIS Express Physical Path from Command Line

I have a project which physical path is: C:\\Users\\username\\Documents\\My Web Sites\\WebSite1\\ 我有一个项目的物理路径为: C:\\Users\\username\\Documents\\My Web Sites\\WebSite1\\

How do I obtain that from the command line? 如何从命令行获取该信息? Either with CMD, wmic or powershell it doesn't matter. 使用CMD,wmic或powershell都没有关系。

I am running the IIS Express server manually, with: C:\\Program Files (x86)\\IIS Express>iisexpress.exe in case that helps. 我正在手动运行IIS Express服务器,其中包括: C:\\Program Files (x86)\\IIS Express>iisexpress.exe ,以防万一。

For the IIS Server I can do this: 对于IIS服务器,我可以这样做:

cat C:\Windows\System32\inetsrv\config\applicationHost.config | sls "physicalPath"

and then: 接着:

dir env:SystemDrive

I am not sure if there is another option 我不确定是否还有其他选择

Here is the best solution I have found: 这是我找到的最佳解决方案:

$assembly = [System.Reflection.Assembly]::LoadFrom("$env:systemroot\system32\inetsrv\Microsoft.Web.Administration.dll")

$iis = new-object Microsoft.Web.Administration.ServerManager "$env:systemroot\system32\inetsrv\config\applicationhost.config"

foreach ($site in $iis.Sites) { echo $site.Applications["/"].VirtualDirectories["/"].PhysicalPath; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM