|
How to run
a ZENworks Application Once and only Once Per Day
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.
http://www.ithowto.com/ftp/onceday.axt
|