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

I have a batch file that makes a directory on H:\ and copies all of my CS work from I:\ to H:\ ( our I:\ drive isn't always available ). Is there a way to possibly run this batch file on logoff so that my files are always updated, WITHOUT using gpedit.msc (access denied)?

I am on a student computer, so most likely installing software won't to practical, but I could try. And help would be much appreciated =)

Or is there a way to run a batch file, and not have the commands run until like.. 8:50 before the bell rings, so I could just put it in the Startup folder and it could run at that time?

I thought about it some more, and the easiest way would be to set a scheduled task at 8:50 for it to run.. but it would still be nice if I knew how to to do in a batch file. I don't have access to the shutdown -l commands, and I don't believe that would help anyways because I want the script to run when I click 'Log Off'.

share|improve this question

This should do the trick. Save as a REG file and import, unless that is blocked as well. This effectively creates a logoff script entry.

"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00 ,00,00,00,00,00

Save your script to do the copy under the root of your H: drive.

share|improve this answer
Can I use it if my O.S (Windows 7 Home Premium) doesn't have a pre-installed gpedit.msc? – user3133076 Dec 23 '14 at 9:52

Another similar option to what Tim Brigham already suggested is to save the text below as a .reg file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Logoff\0]
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Logoff\0\0]

This is similar to doing it yourself from the Group Policy Editor tool (gpedit.msc).

share|improve this answer
Welcome to Super User! You've got a great answer for a new user, better than a lot of others I've seen. If you need help, be sure to follow the tour and check out the help center. We hope you enjoy participating on Stack Exchange! – bwDraco Dec 6 '14 at 3:14

you can put that line at the end of your batch file

shutdown -l

this will log you off as soon as the script is done

share|improve this answer
I know this is a late comment, but I didn't use this command because A) I don't have the access rights and b) I wouldn't want another user in the next class period to use my computer if it were to take longer than usual – cutrightjm Mar 25 '12 at 3:53

I'm not sure which version of Windows added this program, but you could use the waitfor command to pause a batch file for 3,000 seconds (i.e. 50 minutes), then continue with your copy command.

It's definitely available in Windows 7, almost certainly in Vista, and not in XP. However, it may be available in the Windows 2003 Resource Kit Utilities that are available to download, which will run on XP.

There's probably some batch trickery that's possible to pause a script for a particular amount of time too.

share|improve this answer
up vote 1 down vote accepted

I eventually just used Scheduled Tasks and set the batch file to run at 8:50, that should work.

share|improve this answer

Start -> Run and type "gpedit.msc"

Under User Configuration -> Windows Settings -> Scripts (Logon/Logoff) you can add your scripts

share|improve this answer
The OP explicitly stated that access to gpedit.msc was denied. – afrazier Oct 11 '11 at 13:37
I upvoted this answer just to make sure that it stays here as a reference. I know it's weird to give an answer which the OP (specifically) doesn't want. But it's good that it's here IMO. – Shashank Sawant Oct 10 '14 at 21:46

You must log in to answer this question.

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