Xxx_AutoDeployIIS.bat 文件内容如下:
:得到批处理文件所在目录,由于批处理文件放在网站跟目录下,所以即是得到网站的完整目录路径
@set "sitePath=%~dp0"
@set "sitePathDer=%~d0"
@set "sitePathFile=%cd%"
:更改当前目录及其所有子目录中指定文件的
@echo Access Configuration start...
%sitePathDer%
cacls %sitePathFile% /t /e /g everyone:f
@echo Access Configuration finished...
echo=
:得到批处理文件所在目录,由于批处理文件放在网站跟目录下,所以即是得到网站的完整目录路径
@set "sitePath=%~dp0"
:应用程序池名称
@set ApplicationPool_Name="NET50528Pool"
:应用程序池.NETCLR版本 示例:""->无托管代码,"v4.0","v2.0"
@set ApplicationPool_NETCLRVersion=""
:IISWeb站点名称
@set WebSiteName="NET5Demo"
:IIS站点端口
@set WebSitePort="8567"
:启用32位应用程序;默认:false;支持 true 或者 false;
@set Enable32BitAppOnWin64="false"
@echo off
echo=
@echo ---------------------------------------------------
@echo Start Deploy WebSite %WebSiteName%
echo=
:新建应用程序池
@echo Create IIS ApplicationPool start...
@C:\Windows\System32\inetsrv\appcmd.exe add apppool /name:%ApplicationPool_Name% /managedRuntimeVersion:%ApplicationPool_NETCLRVersion% /Enable32BitAppOnWin64:%Enable32BitAppOnWin64%
@echo Create IIS ApplicationPool finished...
echo=
:新建IIS站点
@echo Create IIS Web Site start...
@C:\Windows\System32\inetsrv\appcmd.exe add site /name:%WebSiteName% /bindings:http/*:%WebSitePort%: /applicationDefaults.applicationPool:%ApplicationPool_Name% /physicalPath:%sitePath%
@echo Create IIS Web Site finished...
echo=
:停止一下IIS站点
@echo stop WebSite start...
@C:\Windows\System32\inetsrv\appcmd.exe stop site %WebSiteName%
@echo stop WebSite finished...
echo=
:启动IIS站点
@echo Restart WebSite start...
@C:\Windows\System32\inetsrv\appcmd.exe start site %WebSiteName%
@echo Restart WebSite finished...
echo=
::新建虚拟目录
::@echo Create Virtual Directory start...
::在 Net5Demo 站点下添加虚拟目录 ,虚拟目录名称 test,虚拟目录指向目录:D:\000Temp\publish\vir
::@C:\Windows\System32\inetsrv\appcmd.exe add vdir /app.name:"NET5Demo/" /path:"/test" /physicalPath:"D:\000Temp\publish\vir"
::在NET5Demo站点下 应用程序 111 下 添加虚拟目录 ,虚拟目录名称 222;虚拟目录指向路径:D:\000Temp\publish\vir
::@C:\Windows\System32\inetsrv\appcmd.exe add vdir /app.name:"NET5Demo/111" /path:"/222" /physicalPath:"D:\000Temp\publish\vir"
::@echo Create Virtual Directory finished...
::echo=
::WebSite下添加应用程序
::@echo Add Application Under Website start...
::@C:\Windows\System32\inetsrv\appcmd.exe add app /site.name:"NET5Demo" /applicationPool:"web3" /path:"/web3" /physicalPath:"D:\000Temp\publish\vir"
::@echo Add Application Under Website finished...
::echo=
::查看所有站点
::@C:\Windows\System32\inetsrv\appcmd.exe list site
::查看所有应用程序池
::@C:\Windows\System32\inetsrv\appcmd.exe list apppool
@echo Finished Deploy WebSite %WebSiteName%
echo=
@echo ---------------------------------------------------
echo=
Pause