Run Once question

  • Thread starter Thread starter Jayjay
  • Start date Start date
J

Jayjay

I need to have a file run on every computer in the organization, so I
add a command to the logon script to create a runonce entry in the
registry.

The first time the user logs in, the entry is added
The 2nd time the user logs in, the entry is run and then deleted.
The 3rd time the user logs in, the entry is re-added.

I may need to leave the command in the logon script for up to 3 weeks
in order to catch all the users in the organization. How can I
prevent the loop of redoing the process every 3rd login?
 
Hi,

One way to do this would be to create a new regkey to
keep track of if this script ran. As part of the logon
script, check for your new regkey; if it is set to "true"
you do not need to do the install again.

Tony Yuhas
Microsoft
Active Directory Tools
 
I need to have a file run on every computer in the organization, so I
add a command to the logon script to create a runonce entry in the
registry.

The first time the user logs in, the entry is added
The 2nd time the user logs in, the entry is run and then deleted.
The 3rd time the user logs in, the entry is re-added.

I may need to leave the command in the logon script for up to 3 weeks
in order to catch all the users in the organization. How can I
prevent the loop of redoing the process every 3rd login?

Since you are already familiar with adding registry keys, you could add
your own custom key to the registry that flags the system as having been
processed already. Then make the running of your process dependent on the
state of that key. This is especially clean if the program you are running
via "run once" returns error codes. If the error code equals success you
then add the custom key and the system is flagged.

Naturally you'd put the custom key in HKEY_Local_Machine so that the key
wouldn't depend on what user is logged on. But I assume you are doing that
with the run once anyway.

Obviously if the run once process changes any registry keys then you just
check for them instead of creating your own. But creating your own custom
admin registry entries can be useful for all sorts of other things anyway.

Otherwise, if whatever you are running on the systems installs files
somewhere, you can use an "if exist" statement in the logon script that
checks to see if the files are there already and skip the process if they
are.

Or, if the process isn't installing files, you can just install one of your
own somewhere on the system to flag it as having been processed already and
then use the "if exist" statement to check for it.

Or, have the run once process capture the machine name and add it to a
database of systems that have run the process. Check the database from the
logon script and if the machine isn't in there, run the process.
 
Back
Top