Close running version of program before installing update (Inno Setup)

前端 未结 10 1243
囚心锁ツ
囚心锁ツ 2020-12-23 12:24

This should be simple, I need to stop any previous version of my program from running when the installer starts.

Most people suggested making an exe wh

10条回答
  •  半阙折子戏
    2020-12-23 13:01

    I tried using the accepted answer (and the follow up by jachguate) but it wouldn't kill my application. It looks like part of the reason was that my application window had no text associated with it but whatever is the real reason, I used shell command to kill it and that worked. In the [code] section, you want to add the following function. It is called just before setup files are copied.

    function PrepareToInstall(var NeedsRestart: Boolean): String;
    var
    ErrorCode: Integer;
    begin
          ShellExec('open',  'taskkill.exe', '/f /im MyProg.exe','',SW_HIDE,ewNoWait,ErrorCode);
    end;
    

提交回复
热议问题