Appcmd.exe是IIS7提供的一个管理站点的命令行工具,同时支持Ftp和Http的站点,功能还算强大,具体使用方法参考微软网站。
我这里的例子主要配置一个Ftp站点,并且允许CcUser这个用户对其目录具备读和写的权限:
@echo off set cc_inbox_dir=c:\CC_Inbox set cc_outbox_dir=c:\CC_Outbox set appcmd_exe=%systemroot%\system32\inetsrv\appcmd.exe set ftp_siet_name=CC_Inbox ::create cc inbox folder ::rd /S /Q %cc_inbox_dir% IF NOT EXIST %cc_inbox_dir% (md %cc_inbox_dir%) ::create cc outbox folder ::rd /S /Q %cc_outbox_dir% IF NOT EXIST %cc_outbox_dir% (md %cc_outbox_dir%) ::delete the ftp site and then make a new one. ID of the ftp site will be auto-generated. %appcmd_exe% delete site %ftp_siet_name% %appcmd_exe% add site /name:%ftp_siet_name% /bindings:ftp://*:21 /physicalpath:%cc_inbox_dir% ::add virtual dir for cc outbox. Note there is "/' at the end of the app.name %appcmd_exe% add vdir /app.name:"%ftp_siet_name%/" /path:/outbox /physicalpath:%cc_outbox_dir% ::config ftp authentication %appcmd_exe% set site %ftp_siet_name% -ftpServer.security.ssl.controlChannelPolicy:SslAllow -ftpServer.security.ssl.dataChannelPolicy:SslAllow -ftpServer.security.authentication.basicAuthentication.enabled:true ::config ftp authorization to allow CcUser to read and write %appcmd_exe% set config %ftp_siet_name% -section:system.ftpServer/security/authorization /+"[accessType='Allow',users='CcUser',permissions='Read, Write']" /commit:apphost