How do I change the physical path of web site in IIS7 with APPCMD?

后端 未结 5 1198
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 03:24

I need to change the physical path of a web site through the command line via the appcmd.exe tool, but I can\'t figure out the syntax. Can someone help?

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 03:41

    And in case you are trying to change the physical path of a Web Application, here is an example changing the Web Application "Spockadoodle" that is created under Web Site "Default Web Site" to have the physical path "C:_junk".

    appcmd set app /app.name:"Default Web Site/spockadoodle"  -[path='/'].physicalPath:c:\_junk
    

    I figured this out by running the command:

    appcmd set app /app.name:"Default Web Site/spockadoodle"  /?
    

    and in the output I observed

    ERROR (message:-path
    -applicationPool
    -enabledProtocols
    ...
    -[path='string'].physicalPath
    

    and prior to that, in the output of the command

    appcmd set apps /?
    

    the output mentioned:

    Example: appcmd set app "Default Web Site/" /enabledProtocols:http

    Sets the "enabledProtocols" property of the application "Default Web
    Site/".
    

    So, from the example citing how to set "enabledProtocols", I substituted the example of [path='string'].physicalPath

    To know the value for the attribute expression [path='string'] I observed in the output of the command

    appcmd list app "Default Web Site/spockadoodle" /config
    

    output shows that the Web App Spockadoodle has path attribtue value "/":

    Also, I figured out to use the /app.name identifier from examples on the website http://www.iis.net/learn/get-started/getting-started-with-iis/getting-started-with-appcmdexe

提交回复
热议问题