Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Logon/Logoff scripts in Windows XP Professional

Logon/Logoff scripts in Windows XP Professional

Logon/Logoff scripts in Windows XP Professional

Can somebody direct me to a good, quick tutorial on the syntax for Windows XP Pro logon/logoff scripts?  I tried to write a batch file for my logoff script, but it wouldn't work.

(What I want to do is run an executable with a couple of command-line switches, so if there's a tutorial that cuts all of the other stuff and gets right to that, that would be great)

RE: Logon/Logoff scripts in Windows XP Professional

Seeming no one else answered this I thought I might have a go, although I don't know much about batch files.  At least it will bump your post up the forum list.

Unless you use DOS 8.3 name conventions in your batch files, include the full path to your exe in "".  After the last " go one space then /with switch.

Now someone can tell you how to really do it.

RE: Logon/Logoff scripts in Windows XP Professional

There are a several steps involved in getting this to work:

1. Create a .bat (or .cmd) script in the proper folder. Use quotes around any commands with spaces in the path. The scripts go in C:\Windows\system32\GroupPolicy\Machine(or User)\Shutdown(or Startup)

2. Then you have to run the Group Policy Editor (start, run, gpedit.msc).

3. Then expand "Windows Settings" under "Computer Configuration" if you put your script under "Machine" or "Windows Settings" under "User Configuration" if you put your script under "User."

4. Select "Scripts (Logon/Logoff)". Then select "Logon" or "Logoff." You will find an empty box in the dialog. Click "Add" to finish configuration of your script.

RE: Logon/Logoff scripts in Windows XP Professional

Is there a way to set a logoff script without using the GUI?

My project, when installed, needs to perform a certain function when the user logs off.  I would like to register this script programmatically at install time.  
Is there a command line interface to the Group Policy settings?  Or another way to do this?

Thanks in advance...

RE: Logon/Logoff scripts in Windows XP Professional

All of the group policy settings are stored in the registry.

LogOff scripts are stored in the following key:


Under this key each script that you add is given an index number starting with 0.

To view what values you need set up a LogOff script and then go to the key.

Greg Palmer

Any feed back is appreciated.

RE: Logon/Logoff scripts in Windows XP Professional

I'm actually using Win2K right now for testing (will eventually need it to work for XP too), and this is what I'm seeing:

I create a Logoff script using the Group Policy GUI.
the windows registry key:

gets created with the value:

is this the same way it works on XP?

When I remove the logoff script using the Group Policy GUI, the registry entry goes away.
I recreated the entry manually (something I'll be able to do with install scripts), but my script wasn't executed on logoff.  

I'm looking for something simailar to:

which runs it's values on logon.  I need the opposite, a key to run value(s) on logoff.


RE: Logon/Logoff scripts in Windows XP Professional

you could also try...


especially if you have older (Win9x) clients

RE: Logon/Logoff scripts in Windows XP Professional

You should consider that any software that tries to make policy changes during installation is likely to fail on most user machines.  You should also consider that many system administrators would not consider purchasing software that attempts to directly change their policy setttings.

You might consider a non-policy approach to the issue.  For example, LastChance:  http://www.webattack.com/get/lastchance.html

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close