我想为启动过程正确获取返回代码。即使启动过程以错误结束,它也不会正确地抛出重新编码。如果我在run.bat中遇到错误,也不会触发错误处理代码。 我的代码有什么问题
感谢您的支持。
$errorlog = "D:\EmailConnector-Disc Optimus\logs\error.log"
$emailconnecter_log = "D:\EmailConnector-Disc Optimus\logs\connector.log"
#1 print "Running email bat file...... \n";
Write-Host "Running email bat file...... \n"
$prog="cmd.exe"
$params=@('/C','"D:\EmailConnector-Disc Optimus\run.bat"','connector.log')
$rc = start-process $prog $params -WorkingDirectory "D:\EmailConnector-Disc Optimus" -RedirectStandardOutput $emailconnecter_log -PassThru -wait
if (-not $?)
{
Write-Host $rc
$status = "running Daily email bat file failed on $hostname"
Del_Daily
Del_Dat
Send_Mail
exit
}
else
{
Write-Host $rc
Write-Host "Email send sucess fully....."
}