1、shellexec
ShellExec('open','taskkill.exe','/f /im {#MyAppExeName}','',SW_HIDE,ewNoWait,ErrorCode); ShellExec('open','tskkill.exe',' {#MyAppName}','',SW_HIDE,ewNoWait,ErrorCode);
2、cmd
[UninstallRun]
Filename: "{cmd}"; Parameters: "/C ""taskkill /im MustsWatcher.exe /f /t"
Filename: "{cmd}"; Parameters: "/C ""taskkill /im MUSTSYS.exe /f /t"
3、注册表
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "mustsWin"; ValueData: "{app}\Watcher\MustsWatcher.exe"
例子:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "JOS"
#define MyAppVersion "1.0.0.8"
#define MyAppExeName "MUSTSYS.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{E5025D4B-4E2F-4101-8BC6-392756C41AC0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
DefaultDirName=C:\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\lys\Desktop
OutputBaseFilename=mustc
Compression=lzma
SolidCompression=yes
UsePreviousAppDir=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\JOS\bin\MUSTSYS.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
Source: "C:\JOS\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[code]
//删除所有配置文件以达到干净卸载的目的
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
if MsgBox('您是否要删除用户配置信息?', mbConfirmation, MB_YESNO) = IDYES then
//删除 {app} 文件夹及其中所有文件
DelTree(ExpandConstant('{app}'), True, True, True);
end;
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "mustsWin"; ValueData: "{app}\Watcher\MustsWatcher.exe"
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\bin\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{group}\启动保活程序"; Filename: "{app}\启动保活程序.bat"
Name: "{group}\停止保活程序"; Filename: "{app}\停止保活程序.bat"
Name: "{commondesktop}\musts"; Filename: "{app}\bin\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\Watcher\MustsWatcher.exe";Flags: nowait postinstall skipifsilent
Filename: "{app}\bin\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[UninstallRun]
Filename: "{cmd}"; Parameters: "/C ""taskkill /im MustsWatcher.exe /f /t"
Filename: "{cmd}"; Parameters: "/C ""taskkill /im MUSTSYS.exe /f /t"