Go NSIS: Check if the program is running when installing or uninstalling

Source: Internet
Author: User



Original link http://www.flighty.cn/html/bushu/20110402_115.html






If the program that we are installing or upgrading is running, the file will definitely replace the failure, and the following code can prompt the user to end the running program.



Need to use plugin FindProcDLL.dll, download path: http://nsis.sourceforge.net/FindProcDLL_plug-in



Http://files.cnblogs.com/files/z5337/FindProc.zip



Http://files.cnblogs.com/files/z5337/KillProcDll%26FindProcDll.zip






Check that Flighty.exe is running when you start the installation:



Function .onInit
   ; Close the process
   Push $ R0
   CheckProc:
     Push "flighty.exe"
     ProcessWork :: existsprocess
     Pop $ R0
     IntCmp $ R0 0 Done
     MessageBox MB_OKCANCEL | MB_ICONSTOP "The installer detected that $ {PRODUCT_NAME} is running. $ \ R $ \ n $ \ r $ \ nClick OK to force close $ {PRODUCT_NAME} and continue with the installation. $ \ R $ \ nClick" Cancel "Exits the installer." IDCANCEL Exit
     Push "flighty.exe"
     Processwork :: KillProcess
     Sleep 1000
     Goto CheckProc
     Exit:
     Abort
     Done:
     Pop $ R0
FunctionEnd


Check that Flighty.exe is running when uninstalling starts:






Function un.onInit
   MessageBox MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2 "Are you sure you want to completely remove $ (^ Name) and all its components?" IDYES +2
   Abort
   ; Check if the program is running
   FindProcDLL :: FindProc "flighty.exe"
    Pop $ R0
    IntCmp $ R0 1 0 no_run
    MessageBox MB_ICONSTOP "The uninstaller detected $ {PRODUCT_NAME} is running, please close it before uninstalling!"
    Quit
    no_run:
FunctionEnd 










Go NSIS: Check if the program is running when installing or uninstalling


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.