I'm using code I found in the user guide to wait for a process is process to stop. However, how do I set a limit to how long it runs for, and display an error if it doesn't stop?

<showprogressdialog> <title>Waiting for myapp.exe to exit</title> <actionlist> <while> <actionlist> <wait> <ms>1000</ms> </wait> </actionlist> <conditionrulelist> <processtest> <logic>is_running</logic> <name>myapp.exe</name> </processtest> </conditionrulelist> </while> </actionlist> </showprogressdialog>

thanks.

asked 16 Mar '12, 12:48

bstoke's gravatar image

bstoke
16222224
accept rate: 0%


You could use the below code:

<showProgressDialog>
    <title>Waiting for myapp.exe to exit</title>
    <actionList>
        <setInstallerVariable name="tries" value="0"/>
        <while>
            <actionList>
                <wait>
                    <ms>1000</ms>
                </wait>
               <mathExpression>
                  <text>${tries}+1</text>
                  <variable>tries</variable>
               </mathExpression>
               <break>
                    <ruleList>
                      <compareValues>
                         <logic>greater_or_equal</logic>
                         <value1>${tries}</value1>
                         <value2>6</value2>
                      </compareValues>
                    </ruleList>
               </break>
            </actionList>
            <conditionRuleList>
                <processTest>
                    <logic>is_running</logic>
                    <name>myapp.exe</name>
                </processTest>
            </conditionRuleList>
        </while>
    </actionList>
</showProgressDialog>

<throwError text="The program did not stop!">
    <ruleList>
       <compareValues>
          <logic>greater_or_equal</logic>
          <value1>${tries}</value1>
          <value2>6</value2>
       </compareValues>
       <processTest>
          <logic>is_running</logic>
          <name>myapp.exe</name>
       </processTest>
    </ruleList>
</throwError>
link

answered 16 Mar '12, 13:06

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

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:

×4
×3

Asked: 16 Mar '12, 12:48

Seen: 978 times

Last updated: 16 Mar '12, 13:06