我有一个cmd文件,它调用一个msi并传递参数。我从powershell脚本调用此deploy.cmd文件。我怎么能做到这一点?
我可能在这里遗漏了一些东西。
这就是我的cmd的样子,
Msiexec /i ABCInstaller.msi ^
DB.SERVER=ABC\QA ^
APPLICATION.ENV.TYPE=Qa ^
SVCIDENTITY=SVC-QA@ABC.com ^
SVCPASSWORD=xxx ^
LOCAL.EMAILING="true" ^
EMAIL.GMAT="tarun.arora@abc.com" ^
EMAIL.GMATR="tarun.arora@abc.com" ^
EMAIL.SUCCESSFUL.VALIDATION.SUBJECT="[QA] Successful validation of ABC Message" ^
/lv "ABC_Installer_QA_Log.txt"
这就是我的powershell脚本的样子,
# Assigning Build Number and Drop Location for the MSI in scope
$buildNumber = $TfsDeployerBuildData.BuildNumber
$dropLocation = $TfsDeployerBuildData.DropLocation
# Assign values
if($buildNumber -eq $null)
{
$buildNumber = $args[0]
$dropLocation = $args[1]
}
# Move old uninstall folder to Archive folder
Move-Item "D:\deploy\ABC_Uninstalled\*" "D:\deploy\ABC_Archive" -force
# Move old build folder to uninstalled folder
Move-Item "D:\deploy\ABC_Installed\*" "D:\deploy\ABC_Uninstalled" -force
# Logging
Add-Content -Path "C:\Log\TfsDeployer_Log.txt" -Value $dropLocation
Add-Content -Path "C:\Log\TfsDeployer_Log.txt" -Value $buildNumber
# Copy the msi from drop location to local physical drive
Copy-Item $dropLocation "D:\deploy\ABC_Installed" -recurse
Add-Content -Path "C:\Log\TfsDeployer_Log.txt" -Value "Copied the Msi to D:\deploy\Installed"
# Start execution
& "D:\deploy\ABC_Installed\$buildNumber\en-us\ETRM_QA.cmd"
然而,当执行ps时,它打印出cmd文件中的内容而不是执行它,因此执行的输出是
Output: C:\WINDOWS\system32>Msiexec /i ABCInstaller.msi ^
DB.SERVER=ABC\QA ^
APPLICATION.ENV.TYPE=Qa ^
SVCIDENTITY=SVC-QA@ABC.com ^
SVCPASSWORD=xxx ^
LOCAL.EMAILING="true" ^
EMAIL.GMAT="tarun.arora@abc.com" ^
EMAIL.GMATR="tarun.arora@abc.com" ^
EMAIL.SUCCESSFUL.VALIDATION.SUBJECT="[QA] Successful validation of ABC Message" ^
/lv "ABC_Installer_QA_Log.txt" /passive T
未执行cmd文件: - (
答案 0 :(得分:0)
尝试:
Invoke-Expression "D:\deploy\ABC_Installed\$buildNumber\en-us\ETRM_QA.cmd"
答案 1 :(得分:0)
MsiExec可能正在执行,您只是没有看到它,因为它作为后台进程启动,立即将控制权返回给cmd。例如,如果我创建一个如下所示的cmd脚本:
"C:\Program Files\Microsoft Office\Office11\WINWORD.EXE"
并像这样调用它:
&launchWord.cmd
我在powershell控制台上看到的只是cmd脚本的内容,但是在另一个窗口中打开了word。 你确定msiexec不只是启动和失败,而不是没有启动?