appcmd add site /name:"MyWebsite" /physicalpath:"D:WebsitesMyWebsite" /port:80 /bindings:"*:80:"
批量创建网站
为了批量创建网站,我们可以将上述命令保存到一个批处理文件中,并运行该文件。
以下是一个批处理文件的示例,它包含了创建多个网站的命令:
@echo off
setlocal
:: 网站列表
set "websites=(MyWebsite1 D:WebsitesMyWebsite1 80 *:80:) (MyWebsite2 D:WebsitesMyWebsite2 80 *:80:) (MyWebsite3 D:WebsitesMyWebsite3 80 *:80:)"
:: 遍历网站列表并创建
for /f "tokens=1,2,3,4 delims=()" %%a in (%websites%) do (
set "name=%%a"
set "path=%%b"
set "port=%%c"
set "bindings=%%d"
echo Creating site: %name%
appcmd add site /name:"%name%" /physicalpath:"%path%" /port:%port% /bindings:"%bindings%"
)
echo All sites have been created.
endlocal