Create a logoff script/task for Windows

1

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).

warren

Posted 2009-11-04T09:09:43.183

Reputation: 8 599

Which version of Windows? – Snark – 2009-11-04T09:11:10.417

yes - XP, Vista, and 7 – warren – 2009-11-04T09:11:31.383

Answers

5

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.

Dave Webb

Posted 2009-11-04T09:09:43.183

Reputation: 10 126

you can use GPs without AD? I did not know that – warren – 2009-11-05T18:36:08.947

Essentially all a GP does is update some Registry Keys. This tool allows you to edit the same keys directly. – Dave Webb – 2009-11-05T20:49:33.967

gpedit.msc is not available on XP Home (haven't looked on my Pro box yet) – warren – 2009-11-09T16:25:13.997

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 – 2009-11-09T16:28:52.897

1+1 for including a screenshot of the right way to do this – AdamV – 2009-11-09T17:23:03.503

does that continue to work for Vista and 7? – warren – 2009-11-15T16:03:30.620

@warren - It worked on my Windows 7 RC system. I don't have a Vista system to try it on but I presume so. – Dave Webb – 2009-11-16T06:05:45.587

cool - looks like the best available route – warren – 2009-11-25T12:31:08.100

1

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'.

Alan B

Posted 2009-11-04T09:09:43.183

Reputation: 337

-1: warren said "Without using AD GPOs", so no Group Policy! – Snark – 2009-11-04T09:24:39.393

1@snark: as the other answer suggests, gpedit.msc works fine in the absence of AD. – quack quixote – 2009-11-09T16:30:09.990

0

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" ...

Otto

Posted 2009-11-04T09:09:43.183

Reputation: 1

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 – 2014-03-07T14:24:15.180