Search the Site


bottom corner

Set up a log off script to do backup

Whenever a user logs off of a Windows machine, we can trigger an action on that event to run a log off script, which can be extremely useful. In this example, we use it to set up a simple file backup procedure.

This page is filed under keyword(s): windows.

One possibility for the Windows log off script is to copy some data from the machine being logged off (perhaps being shut down?) to another for backup purposes. For example, I grab my Firefox settings and make a copy of it at "D:\systemBackup\windows\mozilla\". You may wish to expand this to include others; maybe your FTP program's configuration file that is found in "C:\Program Files"? Or progress of your favorite games? Below is what I have in my log off script, which is written as a batch file.

@echo off
set backupcmd=xcopy /c /d /e /h /r /y

echo Backing up Firefox settings...
%backupcmd% "C:\Documents and Settings\me\Application Data\Mozilla\*.*" "D:\systemBackup\windows\mozilla\"

echo Backing up my docs...
%backupcmd% "C:\docs\*.*" "D:\docs\*.*"

echo Backing up a file...
%backupcmd% "C:\john\doe.txt" "D:\john\doe.txt"

Note that in this example, I made use of the xcopy command found in all versions of Windows. The switches I used with the command allow us to copy only those files that had been changed, so the amount of time required to copy files may not be so much.

To set up this log off script, type in "c:\windows\system32\gpedit.msc" in your Run dialogue and click OK. Go to the User Configuration-Scripts (Logon/Logoff) section and add your script. This script will now fire the next time you log off.

Did you find this page useful? Please consider browsing other articles or subscribing to the RSS feed to keep up with latest.

This page is filed under keyword(s): windows.
Author: C. Peter Chen
Last updated: 28 Mar 2008

bottom corner