::防止中文输出乱码
chcp 65001
::临时设置PATH
set PATH=%SystemRoot%\system32\inetsrv;%PATH%
::列出所有站点
appcmd list site
::站点名称
set sitename="WisdomEducation"
::绑定域名和端口号
set domain="http/*:8080:,https/*:8443:"
::网站源文件物理路径 %~dp0 代码当前目录
::set physicalPath=%~dp0
set physicalPath="E:\publish"
::删除同名程序池
appcmd delete AppPool /AppPool.name:%sitename%
::添加程序池 Classic 经典模式,Integrated 集成模式
appcmd add AppPool /name:%sitename% /managedRuntimeVersion:v4.0 /managedPipelineMode:Classic
::删除同名站点
appcmd delete site /site.name:%sitename%
::创建站点
appcmd add site /name:%sitename% /bindings:%domain% /applicationDefaults.applicationPool:%sitename% /physicalPath:%physicalPath%
::设置站点 默认文档
appcmd set config "%sitename%/" /section:defaultDocument /enabled:true /+files.[@start,value='index.html']
::创建应用程序 应用池可以与站点不同
appcmd add app /site.name:%sitename% /applicationPool:%sitename% /path:"/myApp" /physicalPath:"D:\myApp"
::创建虚拟目录
appcmd add vdir /app.name:"%sitename%/" /path:"/StudyOnLine" /physicalPath:"%physicalPath%\StudyOnLine"
::启动站点
appcmd start site %sitename%
::用浏览器打开
start http://localhost:8080