Inno Setup, pre-uninstall detection process or service

Source: Internet
Author: User

[Reprint]inno Setup, pre-uninstall detection process or service(2015-04-24 17:37:20) reproduced
Tags: Reproduced
Original address:inno Setup, pre-uninstall detection process or service go, two or three miles.

There are a few minor problems with Inno packaging, and here's a summary: Inno.iss part of the content is as follows:
1, 32-bit program PSVince.dll plug-in method.
[Files] Source:psvince.dll; Flags:dontcopy[code]function ismoduleloaded (modulename:ansistring):  boolean;external ' [email protected]: Psvince.dll stdcall ';
2. The Psvince control cannot detect a process under a 64-bit system (Windows 7/server 2008/server 2012), which can be resolved using the following function.
 function isapprunning (const filename:string): Boolean;var fswbemlocator:variant;    Fwmiservice:variant;    Fwbemobjectset:variant;begin Result: = false;      Try Fswbemlocator: = Createoleobject (' WbemScripting.SWbemLocator ');      Fwmiservice: = Fswbemlocator.connectserver (', ' rootCIMV2 ', ', ');      Fwbemobjectset: = Fwmiservice.execquery (Format (' SELECT Name from Win32_Process Where name= '%s ', [FileName]);      Result: = (Fwbemobjectset.count > 0);      Fwbemobjectset: = Unassigned;      Fwmiservice: = Unassigned;    Fswbemlocator: = Unassigned;        except if (ismoduleloaded (FileName)) THEN BEGIN Result: = FALSE;        End ELSE begin Result: = true; End End;end;   
Here, there may be an exception:Exception:swbemlocator: Dependent service or component failed to start
Workaround refer to the following steps :
1. Run the following command at the command prompt:
CD/D%windir%system32wbem
Rename Repository Rep_bak
2. Build A. bat batch file and run it with the following contents:
Mofcomp c:windowssystem32wbemcimwin32.mof
Mofcomp C:WINDOWSSYSTEM32WBEMCIMWIN32.MFL
Mofcomp c:windowssystem32wbemsystem.mof
Mofcomp c:windowssystem32wbemwmipcima.mof
Mofcomp C:WINDOWSSYSTEM32WBEMWMIPCIMA.MFL
3. Run the following command at the command prompt:
CD/D%windir%system32wbem
For%i in (*.MOF,*.MFL) do mofcomp%i
4. Re-register the WMI component and run the following command at the command prompt:
CD/D%windir%system32wbem
For%i in (*.dll) do regsvr32-s%i
For%i in (*.exe) do%i/regserver

Installs and detects if the program is running before installation, and if run ends the process first
function Initializesetup (): Boolean;begin  Result: = true;  If  isapprunning (' {#MyAppExeName} ') then  begin    If MsgBox (' Setup detected {#MyAppName} is running! ' #13 ' #13 ' click ' Yes ' button to close the program and continue installation; ' #13 ' #13 ' click No ' to exit the installation! ', mbconfirmation, mb_yesno) = Idyes then    begin      Taskkillprocessbyname (' {#MyAppExeName} ');      result:= true;    End    Else      result:= false;  End;end;
Uninstall, similar to installation
function Initializeuninstall (): Boolean;  Begin    result:= true;    If  isapprunning (' {#MyAppExeName} ') then    begin      If MsgBox (' Uninstaller detected {#MyAppName} is running! ' #13 ' #13 ' click ' Yes ' button to close the program and proceed with uninstallation; ' #13 ' #13 ' click No ' to exit Uninstall! ', mbconfirmation, mb_yesno) = Idyes then      begin        Taskkillprocessbyname (' {#MyAppExeName} ');        result:= true;      End      Else        result:= false;    End;  End

Inno Setup, pre-uninstall detection process or service

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.