::注意如下的参数设置,用于屏蔽删除不存在对象时的错误提示。 ::Cscript.exe /nologo /b %IIS_Command_Name% ::%IIS_Command_Name% ......................>nul ::==========【【判断Internet Information Services Manager的创建命令模式】】========== set IIS_Command_Version="" if exist %systemdrive%\inetpub\AdminScripts\adsutil.vbs set IIS_Command_Version="adsutil" if exist %systemdrive%\Windows\System32\inetsrv\appcmd.exe set IIS_Command_Version="appcmd" if /i %IIS_Command_Version% == "" goto IIS_Command_Version_Error if /i %IIS_Command_Version% == "adsutil" set IIS_Command_Name=%systemdrive%\inetpub\AdminScripts\adsutil.vbs if /i %IIS_Command_Version% == "appcmd" set IIS_Command_Name=%systemdrive%\Windows\System32\inetsrv\appcmd.exe ::==========【【根据第一个参数判断执行的命令】】========== set IIS_Command_Type=%1% if /i "%IIS_Command_Type%" == "/apppool" goto IIS_Command_AppPool if /i "%IIS_Command_Type%" == "/site" goto IIS_Command_Site if /i "%IIS_Command_Type%" == "/vdir" goto IIS_Command_VDir if /i "%IIS_Command_Type%" == "/app" goto IIS_Command_App ::显示错误命令帮助信息 goto IIS_Command_Help ::==========【【创建应用程序池】】========== :IIS_Command_AppPool set TargetApppool=%2% set TargetVersion=%3% ::====判断是否为【Appcmd版】==== if /i %IIS_Command_Version%=="appcmd" goto IIS_Command_AppPool_Appcmd ::====创建应用程序池【Adsutil版】==== Cscript.exe /nologo /b /h:CScript Cscript.exe /nologo /b %IIS_Command_Name% delete w3svc/apppools/%TargetApppool% Cscript.exe /nologo %IIS_Command_Name% create w3svc/apppools/%TargetApppool% iisapplicationpool Cscript.exe /nologo /b /h:WScript goto IIS_Command_Exit ::====创建应用程序池【Appcmd版】==== :IIS_Command_AppPool_Appcmd %IIS_Command_Name% delete apppool "%TargetApppool%">nul if /i %TargetVersion% == "" set TargetVersion="v4.0.30319" %IIS_Command_Name% add apppool /name:"%TargetApppool%" /managedRuntimeVersion:%TargetVersion:~0,4% /managedPipelineMode:Integrated goto IIS_Command_Exit ::==========【【创建网站】】========== :IIS_Command_Site set TargetName=%2% set TargetBindings=%3% set TargetPhysicalPath=%4% set TargetApppool=%5% set TargetVersion=%6% ::====判断是否为【Appcmd版】============== if /i %IIS_Command_Version%=="appcmd" goto IIS_Command_Site_Appcmd ::====创建网站【Adsutil版】=============== set Microsfot_DoNet_FameWork="" if exist %SystemRoot%\Microsoft.NET\Framework\%TargetVersion%\aspnet_regiis.exe set Microsfot_DoNet_FameWork=%SystemRoot%\Microsoft.NET\Framework\%TargetVersion%\aspnet_regiis.exe if exist %SystemRoot%\Microsoft.NET\Framework64\%TargetVersion%\aspnet_regiis.exe set Microsfot_DoNet_FameWork=%SystemRoot%\Microsoft.NET\Framework64\%TargetVersion%\aspnet_regiis.exe if /i %Microsfot_DoNet_FameWork%=="" goto Microsfot_DoNet_FameWork_Error Cscript.exe /nologo /b /h:CScript Cscript.exe /nologo /b %IIS_Command_Name% stop_server w3svc/%TargetBindings% Cscript.exe /nologo /b %IIS_Command_Name% delete w3svc/%TargetBindings% Cscript.exe /nologo %IIS_Command_Name% create_vserv w3svc/%TargetBindings% Cscript.exe /nologo %IIS_Command_Name% create_vdir w3svc/%TargetBindings%/root Cscript.exe /nologo /b %IIS_Command_Name% appcreateinproc w3svc/%TargetBindings%/root/ Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/servercomment "%TargetName%" Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/serverbindings ":%TargetBindings%:" Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/path %TargetPhysicalPath% Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/accessscript true Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/appfriendlyName DefaultApplication Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/AppPoolId %TargetApppool% Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/defaultdoc default.aspx Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/AuthFlags 5 Cscript.exe /nologo /b %IIS_Command_Name% start_server w3svc/%TargetBindings% Cscript.exe /nologo /b /h:WScript %Microsfot_DoNet_FameWork% /s w3svc/%TargetBindings% goto IIS_Command_Exit :IIS_Command_Site_Appcmd ::====创建网站【Appcmd版】================ %IIS_Command_Name% delete site "%TargetName%">nul %IIS_Command_Name% add site /name:"%TargetName%" /id:%TargetBindings% /physicalPath:%TargetPhysicalPath% /bindings:"http://*:%TargetBindings%" %IIS_Command_Name% set site %TargetName% /[path='/'].applicationPool:%TargetApppool%>nul goto IIS_Command_Exit ::==========【【创建虚拟目录】】========== :IIS_Command_VDir set TargetName=%2% set TargetBindings=%3% set TargetPath=%4% set TargetPhysicalPath=%5% ::====判断是否为【Appcmd版】============== if /i %IIS_Command_Version%=="appcmd" goto IIS_Command_VDir_Appcmd ::====创建虚拟目录【Adsutil版】=========== Cscript.exe /nologo /b /h:CScript Cscript.exe /nologo /b %IIS_Command_Name% delete w3svc/%TargetBindings%/root/%TargetPath% Cscript.exe /nologo %IIS_Command_Name% create_vdir w3svc/%TargetBindings%/root/%TargetPath% Cscript.exe /nologo /b %IIS_Command_Name% set w3svc/%TargetBindings%/root/%TargetPath%/path %TargetPhysicalPath% Cscript.exe /nologo /b /h:WScript goto IIS_Command_Exit ::====创建虚拟目录【Appcmd版】============ :IIS_Command_VDir_Appcmd %IIS_Command_Name% delete vdir /vdir.name:%TargetName%/%TargetPath%>nul %IIS_Command_Name% add vdir /app.name:%TargetName%/ /path:/%TargetPath% /physicalPath:%TargetPhysicalPath% goto IIS_Command_Exit ::==========【【创建应用程序】】========== :IIS_Command_App set TargetName=%2% set TargetBindings=%3% set TargetPath=%4% set TargetPhysicalPath=%5% ::====判断是否为【Appcmd版】============== if /i %IIS_Command_Version%=="appcmd" goto IIS_Command_App_Appcmd ::====创建应用程序【Adsutil版】=========== Cscript.exe /nologo /b /h:CScript Cscript.exe /nologo /b %IIS_Command_Name% delete w3svc/%TargetBindings%/root/%TargetPath% Cscript.exe /nologo %IIS_Command_Name% create_vdir w3svc/%TargetBindings%/root/%TargetPath% Cscript.exe /nologo %IIS_Command_Name% set w3svc/%TargetBindings%/root/%TargetPath%/path %TargetPhysicalPath% Cscript.exe /nologo %IIS_Command_Name% appcreateinproc w3svc/%TargetBindings%/root/%TargetPath% Cscript.exe /nologo /b /h:WScript goto IIS_Command_Exit ::====创建应用程序【Appcmd版】============ :IIS_Command_App_Appcmd %IIS_Command_Name% delete app /app.name:%TargetName%/%TargetPath%>nul %IIS_Command_Name% add app /site.name:"%TargetName%" /path:/%TargetPath% /physicalPath:%TargetPhysicalPath% goto IIS_Command_Exit ::==========【【帮助说明】】========== :IIS_Command_Help echo off if /i "%IIS_Command_Type%" == "" cls echo ------------------------------------------------- echo IISCommand.bat 命令说明 echo /apppool 创建运行池 echo 参数 AppPoolName 应用程序池名称 (必要) echo 参数 .NetVersion .net版本 (必要) 兼容 appcmd.exe echo /site 创建网站 echo 参数 SiteName 网站名称 (必要) echo 参数 SiteBindings 网站端口 (必要) echo 参数 SitePath 物理路径 (必要) echo 参数 AppPoolName 应用程序池名称 (必要) echo 参数 .NetVersion .net版本 (必要) 兼容 adsutil.vbs echo /vdir 创建虚拟目录 echo 参数 SiteName 网站名称 (必要) 兼容 appcmd.exe echo 参数 Bindings 网站端口 (必要) 兼容 adsutil.vbs echo 参数 vDirName 虚拟目录名称 (必要) echo 参数 PhysicalPath 物理路径 (必要) echo /app 创建应用程序 echo 参数 SiteName 网站名称 (必要) 兼容 appcmd.exe echo 参数 Bindings 网站端口 (必要) 兼容 adsutil.vbs echo 参数 vDirName 应用程序名称 (必要) echo 参数 PhysicalPath 物理路径 (必要) if /i "%IIS_Command_Type%" == "" echo ------------------------------------------------- goto IIS_Command_Pause ::==========【【FrameWork 版本错误】】========== :Microsfot_DoNet_FameWork_Error cls echo ------------------------------------------------- echo 无法执行该脚本,脚本将终止执行。 echo 请确认您的机器上已安装 Microsfot.NET Framework 版本 %TargetVersion% echo ------------------------------------------------- start mshta vbscript:msgbox("请确认您的机器上已安装 Microsfot.NET Framework 版本 %TargetVersion%。",0,"超图软件")(window.close) got IIS_Command_Error ::==========【【脚本版本错误】】========== :IIS_Command_Version_Error cls echo ------------------------------------------------- echo 无法执行该脚本,脚本将终止执行。 echo 请确认您的机器上已安装 Internet Information Services Manager。 echo ------------------------------------------------- start mshta vbscript:msgbox("请确认您的机器上已安装 Internet Information Services Manager。",0,"超图软件")(window.close) got IIS_Command_Error ::==========【【暂停】】========== :IIS_Command_Pause pause>nul goto IIS_Command_Exit ::==========【【暂停退出】】========== :IIS_Command_Error pause>nul exit ::==========【【结束】】========== :IIS_Command_Exit