Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Without using AD GPOs (Active Directory Group Policy Objects), or similar, how would one go about creating a logoff script for Windows?

This would be for XP (home and pro), Vista, and 7, in a personal environment (ie, no Domain Controllers anywhere in sight).

share|improve this question
Which version of Windows? – Snark Nov 4 '09 at 9:11
yes - XP, Vista, and 7 – warren Nov 4 '09 at 9:11
up vote 5 down vote accepted

In the Run box type gpedit.msc and hit enter. This will open the Group Policy editor. This will allow you to edit the kind of things normally managed by an AD Policy directly on the local machine.

alt text

Under Windows Settings there is a Scripts (Startup/Shutdown) option where you can specify Startup and Shutdown scripts.

share|improve this answer
you can use GPs without AD? I did not know that – warren Nov 5 '09 at 18:36
Essentially all a GP does is update some Registry Keys. This tool allows you to edit the same keys directly. – Dave Webb Nov 5 '09 at 20:49
gpedit.msc is not available on XP Home (haven't looked on my Pro box yet) – warren Nov 9 '09 at 16:25
it's available on my XP Pro box. probably would work fine if you copy the file over to the XP Home box. – quack quixote Nov 9 '09 at 16:28
+1 for including a screenshot of the right way to do this – AdamV Nov 9 '09 at 17:23

On Windows XP Pro, you can assign startup and shutdown scripts (i.e. batch files) using Group Policy. Open the Help And Support Center and search on 'shutdown script'.

share|improve this answer
-1: warren said "Without using AD GPOs", so no Group Policy! – Snark Nov 4 '09 at 9:24
@snark: as the other answer suggests, gpedit.msc works fine in the absence of AD. – quack quixote Nov 9 '09 at 16:30

The two previous answers explain how to execute scripts on startup/shutdown.

The answer to the actual question asked (logon/logoff) is to create a windows task scheduler task where you tie the trigger to be "On connect/disconnect from user session" instead of a more familiar scheduled time or date.

Run taskschd.msc --> create task --> Triggers --> New --> "On connection to user session" ...

share|improve this answer
it would seem, though perhaps I'm mistaken, that this would run even if all you did was disconnect (but NOT logoff) from an RDP session and then reconnected later – warren Mar 7 '14 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .