I have a project which physical path is: 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.
I am running the IIS Express server manually, with: C:\\Program Files (x86)\\IIS Express>iisexpress.exe
in case that helps.
For the IIS Server I can do this:
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; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.