2013-08-23 136 views
1

製作一個將關閉所有打開的瀏覽器的代碼。關閉Nsis中的所有瀏覽器

var hadBrowsers 
Function closeAllBrowsers 
FindWindow $0 "IEFrame" 
IntCmp $0 0 0 closeAll 
FindWindow $0 "MozillaUIWindowClass" 
IntCmp $0 0 0 closeAll 
FindWindow $0 "Chrome_WidgetWin_0" 
IntCmp $0 0 done closeAll 
closeAll: 
MessageBox MB_OK "Please close your browsers or press ok to close them all automatically" 
;Closing all IE Windows 
loop: 
    FindWindow $0 "IEFrame" 
    IntCmp $0 0 skipIE 
    IsWindow $0 0 skipIE 
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)' 
    StrCpy $hadBrowsers "1" 
    skipIE: 
    FindWindow $0 "MozillaUIWindowClass" 
    IntCmp $0 0 skipFF 
    IsWindow $0 0 skipFF 
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)' 
    StrCpy $hadBrowsers "1" 
    skipFF: 
    FindWindow $0 "Chrome_WidgetWin_0" 
    IntCmp $0 0 skipGC 
    IsWindow $0 0 skipGC 
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)' 
    StrCpy $hadBrowsers "1"   
    skipGC: 
    FindWindow $0 "IEFrame" 
    IntCmp $0 0 0 wait 
    FindWindow $0 "MozillaUIWindowClass" 
    IntCmp $0 0 0 wait 
    FindWindow $0 "Chrome_WidgetWin_0" 
    IntCmp $0 0 done wait 
wait: 
    Sleep 100 
    goto loop 
done: 
;MessageBox MB_OK $hadBrowsers 
StrCmp $hadBrowsers "1" 0 +1   
    Sleep 2000 
FunctionEnd 

這是行不通的。

給我一些錯誤。

我想在nsis中做一個代碼,它將關閉所有打開的瀏覽器並重新打開它們。

回答

0

我得到了答案

Section 
Execwait '"$SYSDIR\taskkill.exe" /F /IM chrome.exe /T' 
SectionEnd 

我們可以殺死任何任務。

+1

這對用戶非常不公平 - 在關閉Chrome之前至少添加帶有/無選項的簡單消息框以保存他的工作,否則他會恨你! – Slappy

+0

是的,我只會在我的電腦上進行測試。 – Kundan