Create windows scripts and execute them when logging on or logging off. Windows Logon and Logoff scripts can be set in the group policy editor (gpedit.msc). In a workgroup environment when a windows logon or logoff script is set it works for all the users on that computer. Logoff and Logon scripts can be very useful to perform automated tasks such as take backups synchronize certain files and folder, delete temporary files etc. These scripts can be windows batch files (.bat), VBscripts (.vbs) or any other script than should be run on Logoff or Logon.
This tutorial will describe how to configure logon and logoff scripts in windows and show a practical example of how this can be used day to day. The following are the locations where Logon and Logoff scripts are stored.
C:\WINDOWS\system32\GroupPolicy\User\Scripts\Logon C:\WINDOWS\system32\GroupPolicy\User\Scripts\Logoff
To configure logon and logoff scripts go to Start -> Run and enter gpedit.msc navigate to
User Configuration\Windows Settings\Scripts (Logon/Logoff)
open the desired item (Logon or Logoff) go to add and set the location of the file. You can specify additional parameters if your script requires.
A practical example
Now a situation, you work on a windows computer and before winding up you move all the files to a network mapped drive say Z: The next time you want to work with these files you copy them back to the local partition. This operation can be automated using logon and logoff scripts. When a user logs in all files related to that user is copied from Z: drive to the local C:\Document and Settings\username\My Documents when the user logs off all files from the local filesystem are moved back to the network mapped Z: drive.
First for the logon script, create a file named logon.bat open using a text editor and paste the following command. The Y parameter overwrites any existing files in the destination.
copy -Y "Z:\%username%\*" "C:\Document and Settings\%username%\My Documents\*"
Next for the logoff script create a file named logoff.bat and place the following code
move -Y "C:\Document and Settings\%username%\My Documents\*" "Z:\%username%\*"
Now go to group policy editor and set the files as logon and logoff scripts and see the magic !!!
nokukhanya says
This was short but very resource full to technical support student like myself.