Search code examples
winapinsis

How to restart chrome browser without getting it crashed


I'm killing the process in order to close chrome.exe but when I re-open, it says that chrome has crashed.

I also tried:

FindWindow $0 "Chrome_WidgetWin_0"
${If} $0 <> 0 
    SendMessage $0 0x0112 0xF060 0
${EndIf}

But it doesn't seems to work

The code is NSIS but it uses WIN32 calls (findwindow, sendmessage).

Thanks


Solution

  • To get the correct window that can be closed with WM_SYSCOMMAND you can use:

    FindWindow $0 "Chrome_WidgetWin_0" "" "" "Chrome_RenderWidgetHostHWND"
    System::Call 'user32::GetParent(i r0)i.s'
    pop $0
    
    ${If} $0 <> 0 
        SendMessage $0 0x0112 0xF060 0
    ${EndIf}
    

    But as CodyGray commented, to install a Chrome extension you don't need to restart the browser at all. The documentation is located in Google Chrome Documentation