Say, we have the following scenario:

  • a user has installed my software using BitRock installer already
  • a user downloads a new version (doesn't matter manually or using auto update tool)
  • a user runs installation process but previous version of my software is still running in backgournd.

I would like to do the following: I would like to send some message to my application to ask it to quit. Then the installer should wait until my application is finished and run installation. Than it should restart software if it was terminated on previous step.

I found how to notify a user if my process is running but I haven't found any way to to communicate with external proccess. I would like to have cross-platform solution but it is ok if you suggest something for Windows only.

asked 14 Feb '12, 05:38

Alexander's gravatar image

Alexander
16336
accept rate: 0%


You can use built-in actions and rules to implement checking that process exists and waiting for it to exit. You can either bundle an application that sends an appropriate message (i.e. using SendMessage() API) or use the built-in <kill> action.

The example with shipping an application to quit is as follows:

<readyToInstallActionList>
  <if>
    <actionList>
      <unpackFile>
        <component>tools</component>
        <destination>${system_temp_directory}/myapp-askquit.exe</destination>
        <folder>tools</folder>
        <origin>myapp-askquit.exe</origin>
      </unpackFile>
      <showProgressDialog>
        <title>Requesting myapp to exit</title>
        <actionList>
          <while>
            <actionList>
              <runProgram>
                <program>${system_temp_directory}/myapp-askquit.exe</program>
                <programArguments></programArguments>
              </runProgram>
              <wait>
                <ms>5000</ms>
              </wait>
            </actionList>
            <ruleList>
              <processTest>
                <logic>is_running</logic>
                <name>myapp.exe</name>
              </processTest>
            </ruleList>
          </while>
        </actionList>
      </showProgressDialog>
      <deleteFile>
        <path>${system_temp_directory}/myapp-askquit.exe</path>
      </deleteFile>
    </actionList>
    <conditionRuleList>
      <processTest>
        <logic>is_running</logic>
        <name>myapp.exe</name>
      </processTest>
    </conditionRuleList>
  </if>
</readyToInstallActionList>

This checks that myapp.exe is running, if it is, it asks the application to exit and waits for it to exit. It also shows a progress dialog so user is aware what is happening.

It keeps sending the quit message until the process exits. It can be moved to before the <while> action so that sending the message is only done once.

As for using the <kill> action, you can simply replace <runProgram> with:

<kill>
  <name>myapp.exe</name>
</kill>

This will terminate the application, however, it will prevent asking user to perform certain actions - i.e. ask if it should write unsaved data.

link

answered 14 Feb '12, 05:55

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Thank you very much!

(14 Feb '12, 06:14) Alexander
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×6
×1

Asked: 14 Feb '12, 05:38

Seen: 1,709 times

Last updated: 14 Feb '12, 06:14