I tried to open a new incognito chrome window and want to close it.
$URL = 'www.google.com'
$appInstance = Start-Process -FilePath Chrome -passthru -ArgumentList @( '-incognito', $URL, '--new-window')
Write-Host "App ID : " $appInstance.Id
Stop-Process -ID 3716 -Force
Output
App ID : 3716
Error
Stop-Process : Cannot find a process with the process identifier 3716.
My requirement is if I run the script 5 times then 5 chrome instances are open. Now it should close a specific window depending upon its Process ID.
Can it be possible to do?