Novell Home

How to run a ZENworks Application Once (and only Once) Per Day

Novell Cool Solutions: Trench
By Craig Wilson

Digg This - Slashdot This

Posted: 30 May 2001
 

Often a need arises run an app every day, but only once per day, such as a daily reminder message. Normally, if an application is set to force run, it will run each time the user logs into their machine. If it is set to "run once", it will only run a single time and never again on any day until the administrator changes the "version number."

Using some of the more powerful registry features of ZENworks, it is quite simple to create an application that runs once a day per user or once a day per machine.

The first step is to create a registry entry under the registry portion of the application object in either the HKCU or HKLM section of the registry, depending on whether you want to track by user or machine. The value for this key should simply be the %day%, which represents the current day of the month. This variable does not need to be preset. ZENworks will automatically set this variable. Be sure to set the registry entry to distribute always. In my example, I created the key.

[HKEY_CURRENT_USER\Software\ITHOWTO] "LASTRUN"="%day%"

The result is that each time this application is run, the value for the key "LASTRUN" is set to the day's date. The ZENworks variable %day% always returns the number of the day of the month in string format.

The second step for creating this application is to set a "Registry System Requirement" for this application that checks the value of those keys to be "not equal" to %day%.

By using the variable %day% as part of the system requirements for the application, the requirements for the application will dynamically change each day. The result is that each new day the registry keys will be marked with yesterday's date causing the system the system requirements of "not equal to" to be met. This will allow the application to run again, which will set the key to today's date and prevent it from running again until the next day.

If the HKEY_CURRENT_USER key is used, the application will run once per day per user (profile). If you use the HKEY_LOCAL_MACHINE portion of the registry instead, it will run once per day per machine.

The frequency of the app could also be changed from daily to monthly by simply substituting the variable %month% for %day% throughout the applications. %month% returns the number of the month of the year in string format.

Note: Using my simple example of %day%, there is a theoretical loophole in which if a user only logged in during "x" day of any month, the app would never run more than once since the requirement of "not equal to" would not be met. To avoid such theoretical problems, one could make the app a little more complex and use %day%%month%%year% to close this minor loophole. This way the concatenated value of %day%, %month%, and %year% is guaranteed to be unique everyday.

I have provided a sample AXT file below. The sample will run the program "notepad.exe" once per day. Simply change the executable to match the program you need run on a daily or monthly basis.

AXT_FILE 3.1

[Application Name]
Value=OnceDay #1

[Application Caption]
Value=OnceDay

[Registry Key Create]
Key=HKEY_CURRENT_USER\software

[Registry Key Create]
Key=HKEY_CURRENT_USER\software\ITHOWTO

[Registry Value Create]
Type=String
Flag=Write Always
Flag=Always Distribute Setting
Key=HKEY_CURRENT_USER\software\ITHOWTO
Name=LASTRUN
Value=%day%

[Filter OS Version]
Type=Windows 95
Major Version=4
Minor Version=0
Revision Version=0
Flag=Greater Than or Equal
Flag=Show Always

[Filter OS Version]
Type=Windows NT
Major Version=4
Minor Version=0
Revision Version=0
Flag=Greater Than or Equal
Flag=Show Always

[Filter Registry Data]
Type=Binary
Key=HKEY_LOCAL_MACHINE\Software\ITHOWTO
Value=LASTRUN
Length=5
Data=25 64 61 79 25
Flag=Not Equal
Flag=Show Always

[Filter Registry Data]
Type=Binary
Key=HKEY_CURRENT_USER\Software\ITHOWTO
Value=LASTRUN
Length=5
Data=25 64 61 79 25
Flag=Not Equal
Flag=Show Always

[Application Icon]
File=APP4AE1.ICO

[Application Icon Order]
Value=0

[Application Association Flags]
Flag=Launcher

[Application Platform]
Flag=Windows 95
Flag=Windows NT

[Application Path]
Value=notepad.exe

[Application Flags]
Flag=Not a Disconnectable Application

For More Information

If you have any questions you may contact Craig at craig_d_wilson@yahoo.com


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell