The Client Script

Navigation:  Client commands > Phase: Creation > Create a new Client Command >

The Client Script

Version 1.0.0

This script must run on a client and contain the required commands, since the Client Command is to read off the services of the client.  The concept for this is such that the current date including the time as well as the service name, the status of the service and the start type are to be saved. This requires eight individual commands.

 

Time recording

Firstly, the time should be recorded. You can do this by dragging the command Get date/time with drag script section. State in the Details tab that you want to use the Current Time/Date. Select as format  dd.mm.yyyy, hh.nn . This will give you, e.g. the date 01.12.2010, 16.30 , which is saved in a variable. Enter this variable in the bottom section of the dialog. Create a variable TIME (see Variables).

 

5.3.1.2 - Zeit

Time recording

 

Set variable

Next, you must set a variable. This is necessary because the old data must be deleted before saving the first service read from to prevent the creatieon of duplicate or obsolete entries. However, the newly read and registered services may not be deleted by a subsequent service when saving.

 

5.3.1.2 - Count

 

To set a variable, select the command Set project variable and move it with drag script section. Create a variable with the name COUNT by means of the open dialog. Then enter the number 1as content.

 

Reading of the services

The services of the client are now being read. You can do this with the command WMI Query, which you have to move with drag script section.

 

5.3.1.2 - wmi

 

In the Details tab, select the simple mode. Select as Namespace the drop-down entry root\CIMV2. The associated WMI class is Win32_Service and can be entered manually or by means of the adjacent button. When using the button, a dialog with a list of all WMI classes of the selected namespace appears. It is not necessary to state any conditions, because all the data of the services are to be read.

 

Enter the variable SERVICE as event variable. In this variable, a service is saved, all subordinate commands assigned to this command are executed and the next service is read. The tab Remote Computer does not require any input, since this command will be executed locally.

 

If-condition

To now delete the old data before saving the first recorded servicce, a branch is built into the script. You can do this by moving the If-command into the script and by entering - in the tab Details - the value 1, by entering the previously created variable COUNT (%COUNT%).

 

Since the check will be performed for equality with 1 , the corresponding operator must be selected and for the Value2 the number 1 must be entered. The options here are all the same, since they are numbers, not strings. Then you subordinate this command with the arrow button under the command WMI Query, similar to a subfolder in Explorer.

 

Then-consequence / Save data

If the previously-defined condition is true (Count = 1), all commands which are subject to the If-command (using the arrow button) will be executed.

 

5.3.1.2 - datenSpeichern

 

To the save the data of the previously read service, move the command Store Value on server (Client) into the script. In the tab Details, you can set the option to Store multiple value on the server. It is now very important to activate the option Delete old values . This ensures that the old data are deleted before new data are saved. This option is likewise the reason for the variable COUNT as well as for the If-Else-branch. Since the variable Count is increased later, this command will not be executed again. More on that later.

 

Now search the fields from the section Field, in which the data of the read services are to be saved. By double-clicking, a box at the bottom will appear. In this box, the fields Service name, Status, Start type and Last read will be used. However, these fields were previously created in the Individual Fields.

 

If all the required fields are now arranged in the bottom range (Value), the corresponding values can be assigned to these fields. These values ​​were previously read into in the variable SERVICE , which can now be used:

 


Service name

Status

Start type

Last read from

%SERVICE.caption%

%SERVICE.state%

%SERVICE.startmode%

%TIME%

 

The properties of the variable SERVICE  (caption, state, start mode) are defined by the data of the query (command WMI Query). The variable TIME was defined already at the start  of the script.

 

Else-condition

To save all other services which are read, your first need an Else branch . Drag the appropriate command in the script and allocate it with the help of the arrow buttons to the same column as the If-command .

 

Then-consequence/Save data

Now, all commands are executed, which have been subordinated to the Else-command (by using the arrow buttons).

 

5.3.1.2 - alteWerteLöschen

 

To the save the data of the previously read service, move the command Store Value on server (Client) into the script. In the tab Details, you can set the option to Store multiple value on the server. Do not activate the option Delete old values this time. Thus, the new data of the services are stored, without the old ones being deleted.

 

Now search the fields from the section Field, in which the data of the read services are to be saved. By double-clicking, a box at the bottom will appear. In this box the fields Service name, Status, Start type and Last read from will be used. However, these fields were previously created in the Individual Fields. If all the required fields are now arranged in the bottom range (Value), the corresponding values can be assigned to these fields. These values ​​were previously read into in the variable SERVICE, which can now be used:

 


Service name

Status

Start type

Last read from

%SERVICE.caption%

%SERVICE.state%

%SERVICE.startmode%

%TIME%

 

The properties of the variable SERVICE (caption, state, startmode) are defined by the data of the query (command WMI Query). The variable TIME was created already at the start of the script.

 

Change of variable

To ensure that the old data are deleted only once, in the first run, the variable COUNT must be increased. Only then, the entire construction with the If–Else–condition will function. Drag this command Increase Variable in the script and allocate it with the arrow button to the same column as the If–command. Enter in the tab Details the variable COUNT as variable name and 1 as increment.

 

5.3.1.2 - Ergebnis

 

The Client Command is now complete and can be tested locally.

Last change on 20.02.2017