使用命令行写入IIS

使用命令行写入IIS

问题描述:

我正在尝试使用脚本安装应用程序。此应用程序在IIS中的默认网站下创建一个虚拟目录。 我已经写了这个脚本。这是正确的脚本还是我错过了一些东西。使用命令行写入IIS

cd C:\Users\Administrator\Desktop 
msiexec /qb /i ZFPSetup.msi INSTALLLOCATION="C:\Program Files (x86)\Application" TARGETVDIR="ZFP" WIXUI_EXITDIALOGOPTIONALCHECKBOX=1 /l*v "C:\log.txt" 
iisvdir /create Default Web Site ZFP C:\Program Files (x86)\Application\ZFP 
call "C:\Program Files (x86)\Application\StartKaraf.bat" echo error 

我得到以下错误:

MSI (s) (28:D0) [04:25:58:897]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIF886.tmp, Entrypoint: WriteIIS7ConfigChanges 
WriteIIS7ConfigChanges: Error 0x80070002: Site not found for create application 
WriteIIS7ConfigChanges: Error 0x80070002: Failed to configure IIS application. 
WriteIIS7ConfigChanges: Error 0x80070002: WriteIIS7ConfigChanges Failed. 
CustomAction WriteIIS7ConfigChanges returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) 

使用简单的批处理文件是不是最好的方式去配置IIS。对于这样的系统管理任务,Microsoft创建了PowerShell

看看如何使用PowerShell在这里配置IIS:http://www.iis.net/learn/manage/powershell

下面是如何使用PowerShell在IIS中创建一个虚拟目录的例子:

PS IIS:\> New-Item 'IIS:\Sites\Default Web Site\DemoVirtualDir1' -type VirtualDirectory -physicalPath c:\test\virtualDirectory1 

上面的代码使用PowerShell Snap-In for Creating Applications

祝你好运!

+0

我不擅长的PowerShell。我从某处获得了这个脚本。如果我必须包含以上功能+卸载和安装,我需要对此脚本做些什么更改。你能帮忙吗? –

+0

剧本太长而无法过去。你可以给我一个PowerShell脚本。 –

Error 0x80070002: Site not found for create application

也许这是由缺乏引号引起的,所以不是:

... iisvdir /create Default Web Site ...

尝试:

... iisvdir /create "Default Web Site" ...