Skip to main content

Hi!


I’m facing a lot of problems patching Chrome. If Chrome is running, then it won’t patch, and if user don’t close it in a lot of days the same. So at the end, it takes too much time for applying the patch.


I want to run a simple worklet to stop Chrome process:



EVALUATION



$chrome=Get-Process -Name "chrome" -ErrorAction SilentlyContinue



function checkChrome {



if ($chrome.si -ne 0) {exit 1}

else {exit 0}



}



checkChrome



REMEDIATION



Stop-Process -Name "chrome" -ErrorAction SilentlyContinue

Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -WorkingDirectory "C:\Program Files (x86)\Google\Chrome\Application"



As you see, it just checks if Chrome is running and then it stop the process and starts it. Doing this on localhost works, running from Automox nothing happends.



Any ideas?



Thanks

Modified another worklet posted here to accomplish this - the hard part is getting it “touchless” so the user doesn’ t even know it updated. I’ve noticed in testing that the old flag chrome provided to auto-restore tabs does not work with the latest versions.





#Set the name of the application you want to affect


$process = “chrome”



#Check if $process is running. If it’s running, ask the user to close it, if it isn’t running then >exit quietly.


$process_running = Get-Process $process -ErrorAction SilentlyContinue



if ( !$process_running ) {


#If the process is not running then there’s nothing to do. Exit quietly.


Write-Host “$process was not running: nothing to close.” }


else {


#Play a sound with the pop-up message


ssystem.media.systemsounds]::Hand.play()



#Trigger the pop-up message with a Ok/Cancel option


pSystem.Reflection.Assembly]::LoadWithPartialName(‘System.Windows.Forms’)


$UserResponse = System.Windows.Forms.MessageBox]::Show(“Google Chrome must be > updated on your system. Please save your work and click OK to close the application. IT” , > “Status” , 1)



#If user clicked OK, try to close the app gracefully


if ( $UserResponse -eq “OK” ) {


Write-Host “Closing $process application.”


$process_running.CloseMainWindow()



    ##Optional: Uncomment the stanza below to force kill the process after X seconds if >graceful exit failed

Sleep 60

if ( !$process_running.HasExited ) {

$process_running | Stop-Process -Force }

}

else

#If user clicked Cancel, exit and do nothing

{

Write-Host "Chrome update not applied: user chose to keep the app open."



Exit


}


}




Thanks for that! I’ll try and give you feedback 😉


I’ve made some small changes. The main thing is that if we use “$process_running.CloseMainWindow()” when Chrome is restored, the tabs previously close are not. If we use “Stop-process -name $process” then it restores them.



Running it locally works, but when ran from Automox nothing happends, any idea??



#Set the name of the application you want to affect

$process = "chrome"



#Check if $process is running. If it’s running, ask the user to close it, if it isn’t running then >exit quietly.

$process_running = Get-Process $process -ErrorAction SilentlyContinue



if ( !$process_running ) {

#If the process is not running then there’s nothing to do. Exit quietly.

Write-Host "$process was not running: nothing to close." }

else {

#Play a sound with the pop-up message

bsystem.media.systemsounds]::Hand.play()



#Trigger the pop-up message with a Ok/Cancel option

bSystem.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')

$UserResponse = $System.Windows.Forms.MessageBox]::Show("Para actualizar a la ultima version Chrome debe ser reiniciado. Guarda tu trabajo y haz click en OK para aplicar la actualizacion. Una vez cerrado, puedes iniciar Chrome de nuevo") #> "Status" 1)



#If user clicked OK, try to close the app gracefully

if ( $UserResponse -eq "OK" ) {

Stop-process -Name $process -ErrorAction SilentlyContinue

}

}

Although a worklet is great… I’d advise you to look into Google Chrome Browser Management which handles updates very well.


Reply