I have a cmd file which calls an msi and passes paramters. I am calling this deploy.cmd file from a powershell script. How can i achive this?
I am may be missing something here.
This is what my cmd looks like,
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"
This is what my powershell script looks like,
# Assigning Build Number and Drop Location for the MSI in scope
$buildNumber = $TfsDeployerBuild开发者_开发百科Data.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"
However when the ps is executed, It prints out what is inside the cmd file rather than executing it, so the output of the execution is
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
The cmd file is not executed :-(
Try:
Invoke-Expression "D:\deploy\ABC_Installed\$buildNumber\en-us\ETRM_QA.cmd"
MsiExec likely is executing, you are just not seeing it because it launches as a background process that immediately returns control to cmd. For example, if I create a cmd script that looks like this:
"C:\Program Files\Microsoft Office\Office11\WINWORD.EXE"
And invoke it like this:
&launchWord.cmd
All I see on the powershell console is the contents of the cmd script, but word opens in another window. Are you sure msiexec isn't just launching and failing, rather than failing to launch?
精彩评论