建立站點(放置在站點下運行):app
1 @echo off 2 cls 3 :start 4 echo start 5 set /p sitename="sitename:" 6 @set "physicalpath=%~dp0" 7 echo create site 8 %systemroot%\system32\inetsrv\appcmd add site /name:%sitename% /physicalPath:%physicalpath% /bindings:http/*:80:%sitename% 9 10 echo create application pool 11 %systemroot%\system32\inetsrv\appcmd add apppool /name:%sitename% /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated 12 13 echo bind application pool 14 %systemroot%\system32\inetsrv\appcmd set site /site.name:%sitename% /[path='/'].applicationPool:%sitename% 15 16 echo end 17 set /p choice="Do you want to continue? (y/n) " 18 if not '%choice%'=='y' exit 19 if '%choice%'=='y' goto start
建立應用程序(放置在站點下運行):spa
1 @echo off 2 cls 3 :start 4 echo start 5 set /p sitename="sitename:" 6 set /p appname="appname:" 7 @set "physicalpath=%~dp0" 8 %systemroot%\system32\inetsrv\appcmd add app /site.name:%sitename% /path:/%appname% /physicalPath:%physicalpath% 9 echo create application pool 10 %systemroot%\system32\inetsrv\appcmd add apppool /name:%sitename%.%appname% /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated 11 echo bind application pool 12 %systemroot%\system32\inetsrv\appcmd set app "%sitename%/%appname%" /applicationpool:%sitename%.%appname% 13 echo end 14 15 set choice= 16 set /p choice="Do you want to continue? (y/n) " 17 if not '%choice%'=='y' exit 18 if '%choice%'=='y' goto start
建立虛擬目錄(用戶名和密碼爲訪問虛擬目錄的帳號密碼,沒有可註釋):code
1 @echo off 2 cls 3 echo start 4 set /p sitename="sitename:" 5 @set "physicalpath=E:\path\" 6 @set "vdirname=vdir1" 7 @set "userName=user" 8 @set "password=pwd" 9 %systemroot%\system32\inetsrv\APPCMD add vdir /app.name:"%sitename%/" /path:/%vdirname% /physicalPath:%physicalpath% 10 %systemroot%\system32\inetsrv\APPCMD set vdir /vdir.name:"%sitename%/%vdirname%" /userName:%userName% /password:%password% 11 echo end 12 @pause