I've got a really simple PS script i wrote to open programs when i start my day.
Clear
Write-Host " "
Write-Host " "
Write-Host "Starting Outlook"
Start-Process "C:\Program Files (x86)\Microsoft
Office\root\Office16\OUTLOOK.EXE"
Write-Host `n "Pausing for 5 seconds while Outlook starts."
Start-Sleep 5
Write-Host " "
Write-Host "Starting IE"
Start-Process "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
Write-Host `n "Pausing for 5 seconds while IE starts."
Start-Sleep 5
Write-Host " "
Write-Host "Starting Chrome"
Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Write-Host `n "Pausing for 5 seconds while Chrome starts."
Start-Sleep 5
Write-Host " "
Write-Host "Starting Skype"
Start-Process "C:\Program Files (x86)\Microsoft Office\root\Office16\lync.exe"
Write-Host `n "Pausing for 5 seconds while Skype starts."
Start-Sleep 5
Write-Host " "
Write-Host "Starting Config Manager"
Start-Process "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.exe"
Write-Host `n "Pausing for 5 seconds while Config Manager starts."
Start-Sleep 5
Write-Host " "
Write-Host "Starting Query Tool"
Start-Process "C:\QueryTool\QueryForms.exe"
Write-Host " "
Write-Host "All programs started"
Write-Host " "
Start-Sleep 2
Write-Host "Exiting, have a good day!"
Start-Sleep 2
Exit
Problem is if i run this from my desktop it fails. The PS window opens flashes red text and closes again faster than i can tell what happened. I've seen other posts for this saying to add the -noexit switch, or add a Start-Sleep at the end, or Read-Host -Prompt "Press any key to continue", but none of those work. The error apparently is happening before the script starts. I've set PS and PS (ISE) to run as admin anytime they open, running that script doesn't prompt for admin so it's not being opened as an admin, which is what i'm guessing is wrong.
I don't see any options in the properties to set it to run as admin, or in the right click menu. Right clicking and opening with PS has the same result. Opening PS and running the script works fine.
Ideas?
Oh and i'm on Windows 10 x64, if that matters.