How do I run a batch file at logoff or shutdown?

Z

Zilla

Subject line pretty much says it all. We all know how to exeucte scripts/app
during startup, but what about during logoff/shutdown?
 
Z

Zilla

Sorry I forgot to mentioned that I googled before I posted, and the links
pointed to XP. I didn't find a decent link for Vista.
 
L

Leythos

zilla62 said:
Sorry I forgot to mentioned that I googled before I posted, and the links
pointed to XP. I didn't find a decent link for Vista.

Open a control box (dos shell) and type SHUTDOWN /? and then scroll back
up to see the arguments to the command.

For a restart I normally use:

shutdown /f /r /t 5

If you are a domain admin you can even issue the command to other
computers, something we normally do on a weekend to ensure that
computers are restarted at least once a week.
 
Z

Zaphod Beeblebrox

Zilla said:
Sorry I forgot to mentioned that I googled before I posted, and the
links pointed to XP. I didn't find a decent link for Vista.
The same method that works for XP works for Vista. That said, the
only way I know to do this is using the Group Policy Editor,
gpedit.msc, which isn't available in Home versions of Windows.

If you have a non-Home version, just Start - gpedit.msc - Computer
Configuration - Windows Settings - Scripts (Startup/Shutdown) -
Shutdown. Then use the Add button to add whatever batch file you want
to run on shutdown.

Oh yeah, ignore Leythos' reply, his command will just force a restart
of your PC...

--
Zaphod

Arthur: All my life I've had this strange feeling that there's
something big and sinister going on in the world.
Slartibartfast: No, that's perfectly normal paranoia. Everyone in the
universe gets that.
 
Z

Zilla

Zaphod Beeblebrox said:
The same method that works for XP works for Vista. That said, the only
way I know to do this is using the Group Policy Editor, gpedit.msc, which
isn't available in Home versions of Windows.

If you have a non-Home version, just Start - gpedit.msc - Computer
Configuration - Windows Settings - Scripts (Startup/Shutdown) - Shutdown.
Then use the Add button to add whatever batch file you want to run on
shutdown.

Oh yeah, ignore Leythos' reply, his command will just force a restart of
your PC...

--
Zaphod

Arthur: All my life I've had this strange feeling that there's something
big and sinister going on in the world.
Slartibartfast: No, that's perfectly normal paranoia. Everyone in the
universe gets that.

That explains why I don't have gpedit.msc, I have Vista Home Premium.
Thanks!

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top