Wiki source code of Auf laufende Prozesse überprüfen
Last modified by Jannis Klein on 2024/08/13 08:19
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{aagon.priorisierung}} | ||
2 | 160 | ||
3 | {{/aagon.priorisierung}} | ||
4 | |||
5 | {{aagon.floatingbox/}} | ||
6 | |||
7 | = Initial situation = | ||
8 | |||
9 | Sometimes it is unavoidable that you have to update software or programs that affect all or some of the Clients in your organisation, even during normal working hours. In this case, it is useful to be able to check, for example, whether a particular program is currently being actively used or not, in order to get an overview of how quickly certain updates can be deployed. | ||
10 | |||
11 | This Client Command is needed for software distribution, for example. It checks whether a particular process belonging to a programme that is to be updated is still running. The user can be informed that the program and the associated process should be closed in order to perform such an update. It does not matter whether you are checking Microsoft Word or an Internet browser. In what follows, the Command is designed to be generic, so that you can quickly adapt it specifically for other programs. For this reason, the following use case uses variables (system variables) that require very little customisation and make certain components of the script more flexible and variable. | ||
12 | |||
13 | This use case shows how you can specifically check on the clients whether a particular program or process is running. Mozilla Firefox is used as an example. You will also gain an insight into how to use variables universally. | ||
14 | |||
15 | = Checking for running programs and processes = | ||
16 | |||
17 | == Select a Script == | ||
18 | |||
19 | 1. Navigate to the //Client Commands// > //Create// module. | ||
20 | 1. Click //Add// on the ribbon bar. The Client Command Editor will open and you will need to decide whether it is a Console or Client Script. In this case select Client Script. | ||
21 | |||
22 | == Setting and editing a Command //Set project variable// == | ||
23 | |||
24 | 1. First select the //Variables// > //Set Project Variable// Command from the Command List. | ||
25 | 1. Double click on the Command and select the //General// tab. | ||
26 | 1. Enter a name under the description of the action. In this example, "Set project variable SOFTWARE_NAME to 'Mozilla Firefox'" is inserted. | ||
27 | 1. Switch to the //Details// tab. | ||
28 | 1. Under the variable settings, click on the icon next to the variable name. | ||
29 | 1. Optional: Create a new variable under //Actions//. Name it "SOFTWARE_NAME" and click on the plus icon. Then click the //OK// button to complete the step. | ||
30 | |||
31 | {{aagon.infobox}} | ||
32 | This step is optional if you have not already created the variable. | ||
33 | {{/aagon.infobox}} | ||
34 | |||
35 | 7. Enter the name of the software in the //One line text// box. In this example it is „Mozilla Firefox“. | ||
36 | 8. Click //OK//. | ||
37 | |||
38 | {{figure}} | ||
39 | (% style="text-align:center" %) | ||
40 | [[image:65_Use Case Client Command_Auf laufende Prozesse Variableneinstellungen vornehmen.png]] | ||
41 | |||
42 | {{figureCaption}} | ||
43 | Making variable settings | ||
44 | {{/figureCaption}} | ||
45 | {{/figure}} | ||
46 | |||
47 | == Set and edit Command //Set project variable// == | ||
48 | |||
49 | 1. Select the //Set project variable// Command again. | ||
50 | 1. Double click the Command and open the //General// tab. | ||
51 | 1. Enter the name in the description field, e.g. Set project variable //SOFTWARE_EXE to „firefox.exe“//. | ||
52 | 1. Switch to the //Details// tab. | ||
53 | 1. Optional: Create a new variable under //Actions//. Name it "SOFTWARE_EXE" and click the plus icon. Click //OK //to complete this step. | ||
54 | |||
55 | {{aagon.infobox}} | ||
56 | This step is optional if you have not already created the variable. | ||
57 | {{/aagon.infobox}} | ||
58 | |||
59 | 6. Enter the process name in the Single line text box. | ||
60 | |||
61 | {{aagon.infobox}} | ||
62 | You can query the name of the process using Task Manager by opening the running processes and displaying the name on the //Details// tab. | ||
63 | {{/aagon.infobox}} | ||
64 | |||
65 | Enter the text „firefox.exe“. | ||
66 | 7. Click //OK//. | ||
67 | |||
68 | {{figure}} | ||
69 | (% style="text-align:center" %) | ||
70 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen_Variableneinstellungen vornehmen.png]] | ||
71 | |||
72 | {{figureCaption}} | ||
73 | Setting variables | ||
74 | {{/figureCaption}} | ||
75 | {{/figure}} | ||
76 | |||
77 | {{aagon.warnungsbox}} | ||
78 | With the two Set project variable Commands you have entered two values that you need to check a specific process. In this case you have entered the name of the software (Mozilla Firefox) and the name of the executable file (firefox.exe). If, at a later date, you want to check the whole Command for a different program, you only need to change the first two lines. | ||
79 | {{/aagon.warnungsbox}} | ||
80 | |||
81 | == Insert and customise //Get process ID// Command == | ||
82 | |||
83 | This Command allows you to determine the current process ID of the running process or program. This makes it possible to check, in the ongoing structure of the application example, whether the particular process or program is actively running on a Client or not. | ||
84 | |||
85 | 1. Select the //Process and Shell// > //Get Process ID// Command. | ||
86 | 1. Double click to open the Command. | ||
87 | 1. Under //Process / Target variable//, enable the //... with process// option by clicking the button. | ||
88 | 1. Insert the appropriate variable ~(%SOFTWARE_EXE%). This variable is used to check that Mozilla Firefox is running. | ||
89 | |||
90 | {{aagon.warnungsbox}} | ||
91 | To avoid typing errors, we recommend that you do not enter the variables manually. Instead, either insert them using the icon in the //... with process// line, or press the CTRL + Spacebar combination in the field. This will open the list of variables and you can select the appropriate one. | ||
92 | {{/aagon.warnungsbox}} | ||
93 | |||
94 | {{aagon.infobox}} | ||
95 | The firefox.exe is not explicitly entered here in order to make the Client Commands as variable as possible for other checks. This will allow you to easily change the entries from line 1 and line 2 after the Command is complete and check for other processes by entering a different program there. | ||
96 | {{/aagon.infobox}} | ||
97 | |||
98 | 5. Under //Save results in//, click on the icon to the right of the variable name. | ||
99 | 6. Open Project Variables from the drop down menu at the top. | ||
100 | 7. Enter the name "CHECK_EXE" under the actions and click on the plus icon. | ||
101 | Click //OK// to complete this step. | ||
102 | |||
103 | {{figure}} | ||
104 | (% style="text-align:center" %) | ||
105 | [[image:65_Use Case Client Commands_Variable auswählen.png]] | ||
106 | |||
107 | {{figureCaption}} | ||
108 | Select variable | ||
109 | {{/figureCaption}} | ||
110 | {{/figure}} | ||
111 | |||
112 | {{aagon.infobox}} | ||
113 | You are free to choose any variable name. However, it is recommended that you choose names that are appropriate to the topic so that you can understand exactly what a variable does later in the process. | ||
114 | {{/aagon.infobox}} | ||
115 | |||
116 | 8. The result will be stored in the CHECK_EXE variable. | ||
117 | 9. Then click //OK//. | ||
118 | |||
119 | {{figure}} | ||
120 | (% style="text-align:center" %) | ||
121 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen Get process ID_484.png]] | ||
122 | |||
123 | {{figureCaption}} | ||
124 | Get process ID | ||
125 | {{/figureCaption}} | ||
126 | {{/figure}} | ||
127 | |||
128 | You have now added your first Commands to the Client Script. At this point you can check on your computer to see if the Command works. To do this, click the //Start// button on the quick selection bar or press the F9 key combination. This will run the first three Commands. | ||
129 | |||
130 | Now open the //Run Log// in the lower pane where all the logs of the Client Script are stored. Depending on whether you have the Mozilla Firefox browser open or not, you will see a different value. This is explained by the variable name "CHECK_EXE". If the variable is 0, the programme is not open. If the variable is >0, the program is open and running in the background. In the graphic shown here, the variable is set to 0, so the program is not open. | ||
131 | |||
132 | {{aagon.warnungsbox}} | ||
133 | If the process ID is not running (and therefore 0), the Client Script will encounter an error (see graphic). You should ignore this error by checking the box next to it. This ensures that the 0 is also a valid result in the script and that the Client Command can continue to run. You will then need to check that the value is 0 or greater than 0. | ||
134 | {{/aagon.warnungsbox}} | ||
135 | |||
136 | {{figure}} | ||
137 | (% style="text-align:center" %) | ||
138 | [[image:65_Use Case_Client Commands_Auf laufende Prozesse überprüfen_Durchlauf des CCs_1275.png]] | ||
139 | |||
140 | {{figureCaption}} | ||
141 | Running the client commands to check for running processes | ||
142 | {{/figureCaption}} | ||
143 | {{/figure}} | ||
144 | |||
145 | == Command //If ... Then// insert and customise == | ||
146 | |||
147 | 1. In the Command List, select the //Flow Control// > //If ...// Command. | ||
148 | 1. Double click on the Command to open it and switch to the //General// tab. | ||
149 | 1. Under Action description, enter a name that describes the Command. In this example, "If ~(%CHECK_EXE% <> 0) Then - If the process is running ..." is written so that it is clear in the main field which condition is to be fulfilled here. | ||
150 | 1. Switch to the //Details// tab. | ||
151 | 1. Insert the values to be checked under the conditions. In value 1, the variable //%CHECK_EXE%// must be entered as this is what is to be checked. The variable in value 1 will then be filled when the programme is executed. | ||
152 | 1. Select the unequal operator (< >) to check whether the programme or process is running or not. This operator is particularly suitable because the value can always be different and you can therefore include all possibilities. | ||
153 | 1. Insert the number 0 as value 2. This is the value used as the condition for the operator. | ||
154 | 1. Click //OK// to complete the Command. | ||
155 | |||
156 | {{figure}} | ||
157 | (% style="text-align:center" %) | ||
158 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen If ... then.png||alt="65_Use Case Client Commands_Variable auswählen.png"]] | ||
159 | |||
160 | {{figureCaption}} | ||
161 | If ... Then Command | ||
162 | {{/figureCaption}} | ||
163 | {{/figure}} | ||
164 | |||
165 | If the process is running, the row is completed as the condition is met. If the process is not running, the line is skipped. | ||
166 | |||
167 | == Optional: Set and edit Command //Dialogs// == | ||
168 | |||
169 | You can set this Command as optional if you want your Clients to see a dialogue box informing them that the program should be closed. The message can be customised. Note that the Command must be nested under the previous command (If ~(%CHECK_EXE% <> 0) Then) for it to work correctly. | ||
170 | |||
171 | 1. Select the //Dialogs// > //Dialogs// Command from the Command List. | ||
172 | 1. Open the Command by double clicking on it and open the //Message Settings// tab. | ||
173 | 1. Enter a suitable title for the message. Again, we recommend that you use the project variables and not the name of the program to keep the whole module variable. For example, you could write //Software Update: %SOFTWARE_NAME%//. | ||
174 | 1. Insert the message for the Clients to be displayed when the program is still open. | ||
175 | |||
176 | {{aagon.infobox}} | ||
177 | If you want to use a project variable to use the name of the user in the address, you can use the %LOGGEDONUSER_NAME% variable. | ||
178 | |||
179 | This will use the logged-in user name as the salutation. | ||
180 | {{/aagon.infobox}} | ||
181 | |||
182 | Optional: Change the //message type// and/or available buttons and custom captions. | ||
183 | |||
184 | {{aagon.infobox}} | ||
185 | If you want to see the message text before completing the command, you can do this by clicking the //Preview// button. | ||
186 | {{/aagon.infobox}} | ||
187 | |||
188 | 5. Click //OK//. | ||
189 | |||
190 | {{figure}} | ||
191 | (% style="text-align:center" %) | ||
192 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen Dialog eingeben.png]] | ||
193 | |||
194 | {{figureCaption}} | ||
195 | Enter a dialog | ||
196 | {{/figureCaption}} | ||
197 | {{/figure}} | ||
198 | |||
199 | == Inserting and customising the //Else //Command == | ||
200 | |||
201 | The //Else// block belongs to the previous //If ... Then// Command. Make sure that the Command is inserted at the same level so that the conditions between //If ... Then// and //Else// are completed. | ||
202 | |||
203 | 1. Navigate back to the Command List and select the //Flow Control// > //Else// Command. | ||
204 | |||
205 | {{aagon.infobox}} | ||
206 | Indent this Command, either using the quick selection bar or the shortcut CTRL + left arrow key, so that it appears on the same level as //If ... Then //Command. | ||
207 | {{/aagon.infobox}} | ||
208 | |||
209 | 2. Open the Command by double clicking it. | ||
210 | 3. Optional: Add a comment in case the Else block should be executed. | ||
211 | 4. Click //OK//. | ||
212 | |||
213 | {{figure}} | ||
214 | (% style="text-align:center" %) | ||
215 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen_Else_476.png]] | ||
216 | |||
217 | {{figureCaption}} | ||
218 | Else Command | ||
219 | {{/figureCaption}} | ||
220 | {{/figure}} | ||
221 | |||
222 | == Inserting and editing an //Exit script //Command == | ||
223 | |||
224 | 1. Select //Flow Control// > //Exit script// from the Command List. | ||
225 | 1. Insert the block below the Else Command so that it is indented. | ||
226 | 1. Double click on the Command to open it. | ||
227 | 1. Select the //OK// condition in the //Details// tab. This will mark the script as successful. | ||
228 | |||
229 | {{aagon.infobox}} | ||
230 | If the script fails at this point, you will need to select //Error// from the drop down menu. | ||
231 | {{/aagon.infobox}} | ||
232 | |||
233 | 5. Enter a reason why the Client Commands were successful. | ||
234 | 6. Click //OK// to close the Command. | ||
235 | |||
236 | {{figure}} | ||
237 | (% style="text-align:center" %) | ||
238 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen_Skript beenden_484.png]] | ||
239 | |||
240 | {{figureCaption}} | ||
241 | Exit Script | ||
242 | {{/figureCaption}} | ||
243 | {{/figure}} | ||
244 | |||
245 | Your Client Script should now consist of a total of seven blocks. Save the Client Command. | ||
246 | |||
247 | {{figure}} | ||
248 | (% style="text-align:center" %) | ||
249 | [[image:65_Use Case Client Commands_Auf laufende Prozesse überprüfen.png]] | ||
250 | |||
251 | {{figureCaption}} | ||
252 | Client Command Editor: Checking for running processes | ||
253 | {{/figureCaption}} | ||
254 | {{/figure}} | ||
255 | |||
256 | == Running the Client Command through the phases == | ||
257 | |||
258 | Finally, the client command must be run through the [[Test>>doc:ACMP.65.ACMP-Solutions.Client Commands.Client Command testen.WebHome]], [[Synchronise>>doc:ACMP.65.ACMP-Solutions.Client Commands.Client Command synchronisieren.WebHome]], [[Release>>doc:ACMP.65.ACMP-Solutions.Client Commands.Client Command freigeben.WebHome]] and [[Execute>>doc:ACMP.65.ACMP-Solutions.Client Commands.Client Command ausführen.WebHome]] phases before it can be used. This is the only way to check whether a particular program or process is actively running on a Client. |