[Reprint]inno Setup, pre-uninstall detection process or service(2015-04-24 17:37:20)
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