创建、删除WEB站点的批处理

将下面的代码保存为 *.bat文件,如1.bat然后运行即可实现对IIS服务器里面WEB站点创建、删除

@echo off
:again
setlocal EnableDelayedExpansion
set num=
set sourcepath=
set sitename=
set ip=
set port=
set delweb=
set hosthead=
cls
echo.
echo.
echo --------------------请选择要执行的操作--------------------
echo -----1.创建普通的Web站点
echo -----2.创建具有指定IP地址、端口及主机头的Web站点
echo -----3.删除指定Web站点
echo -----4.退出程序
echo.
echo.
set /p num=请选择要执行的操作:
if "!num!"=="1" (
echo.
set /p sourcepath=请输入站点资源的路径:
set /p sitename=请输入站点的名称:
echo.
iisweb /create !sourcepath! !sitename!
echo 请按任意键退回主菜单...
pause > nul
goto again
)
if "!num!"=="2" (
echo.
set /p sourcepath=请输入站点资源的路径:
set /p sitename=请输入站点的名称:
set /p ip=请输入站点使用的IP地址:
set /p port=请输入站点使用的端口:
set /p hosthead=请输入站点的主机头标识:
echo.
iisweb /create !sourcepath! !sitename! /i !ip! /b !port! /d !hosthead!
echo 请按任意键退回主菜单...
pause > nul
goto again
)
if "!num!"=="3" (
cls
iisweb /query
set /p delweb=请输入要删除的站点名称:
echo.
iisweb /delete !delweb!
echo 请按任意键退回主菜单...
pause > nul
goto again
)
if "!num!"=="4" (
goto exit
)
if "!num!"=="" (
goto again
)
if not "!num!"=="" (
echo 选择错误,请按任意键后重新输入!
pause > nul
goto again
)
:exit
echo 程序已退出!

This entry was posted in Technology. Bookmark the permalink. 4,127 views

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *