2
내 작업은 Outlook이 열려 있는지 여부를 결정하는 스크립트를 만드는 것입니다. 스크립트가 프롬프트를 열고 다음을 묻습니다.실행중인 경우에만 실행
Outlook이 열려 있으면 Outlook을 닫고 스크립트를 계속하거나 아니요를 눌러 스크립트를 종료합니다.
내가 실제로 가지고있는 코드를 제공 할 수 있습니다. 내 문제는 코드가 실제로 실행되고 있는지를 확인하는 것입니다. 즉, Outlook이 닫힌 경우에도 항상 프롬프트가 열립니다.
$ProcessActive = Get-Process outlook.exe -ErrorAction SilentlyContinue
if($ProcessActive -eq $null)
{
#prompt yes or no
$a = new-object -comobject wscript.shell
$intAnswer = $a.popup("Outlook seems to be open; Press Yes if you want to close Outlook and continue or press No to terminate the script", `
0,"Delete Files",4)
If ($intAnswer -eq 6) {
#kill outlook
$ProcessName = "outlook"
If ($Process = (Get-Process -Name $ProcessName -ErrorAction SilentlyContinue)) {
"Closing $($ProcessName) ..." | Write-Host
$Process.Kill()
}
}
#exit script
else {
exit
}
대단히 감사합니다. 내 질문에서 왜 내 "thanks guys"를 삭제했는지 말해 줄 수 있습니까? – Valentino
Stackoverflow 질문은 비슷한 문제에 직면 한 수백 명의 개발자가 읽는 경향이 있습니다. 이와 같은 주석을 제거하면 사용자가 더 빨리 질문을 읽을 수 있습니다. –
좋아요 대단히 고마워요. – Valentino