Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon/Logoff scripts in Windows XP Professional

Status
Not open for further replies.

CitizenBleys

Programmer
Jul 12, 2003
23
CA
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)
 
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.
 
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.
 
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...
 
All of the group policy settings are stored in the registry.

LogOff scripts are stored in the following key:

HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff

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.
 
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:
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff

gets created with the value:
C:\WINNT\System32\GroupPolicy\User\Scripts

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:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

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

Thanks...
 
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:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top