建站批处理
batch_createSites.bat
@echo off
rem 以管理员身份执行本脚本,可添加多条call 以建立多个站点
call path ocreateSites.bat www com.yourdomain yourdomain.com d:Sites
pause
createSites.bat
@echo off
rem 以管理员身份执行本脚本
set domain_id=%1
set site_name_prefix=%2
set domain_postfix=%3
set root_path=%4
set site_name=%site_name_prefix%.%domain_id%
echo %site_name%
set domain_name=%domain_id%.%domain_postfix%
echo %domain_name%
set physical_Path=%root_path%\%site_name%
echo %physical_Path%
mkdir %physical_Path%
inetsrvappcmd add site /name:%site_name% /physicalPath:%physical_Path% /bindings:http/*:80:%domain_name%
inetsrvappcmd add apppool /name:%site_name% /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated
inetsrvappcmd set site /site.name:%site_name% /[path='/'].applicationPool:%site_name%
rem 以下两行用于删除站点和应用程序池
rem inetsrvappcmd delete site /site.name:%site_name%
rem inetsrvappcmd delete apppool /apppool.name:%site_name%
pause
常用appcmd命令
解锁config文件
inetsrvappcmd unlock config -section:system.webServer/modules
inetsrvappcmd unlock config -section:system.webServer/handlers
列出所有iis站点
inetsrvappcmd list site
启用预加载和AlwaysRunning
inetsrvappcmd set apppool %apppool_name% /startMode:AlwaysRunning
inetsrvappcmd set site %site_name% /applicationDefaults.preloadEnabled:True
批量设置站点启用预加载
C:Windowssystem32>inetsrvappcmd list app /xml|%systemroot%system32inetsrvappcmd set site /in /applicationDefaults.preloadEnabled:True
批量设置应用程序池AlwaysRunning
C:Windowssystem32>inetsrvappcmd.exe list app /xml|%systemroot%system32inetsrvappcmd set apppool /in /startMode:AlwaysRunning