Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

is there a way to run a batch script on logoff or shutdown in windows 7 home premium?

[edit] to add a bit of context, im looking to delete everything from my downloads folder when i logoff, so unless someone knows a different way of achieving this?

Thanks

share|improve this question
    
Sadly, without the group policy editor i don't think there is an easy way to make it work. –  bubu Jun 8 '10 at 17:38
add comment

2 Answers

Task Scheduler? Create a new task, and have at least one of the trigger(s) be "At log on".

share|improve this answer
    
+1 for Task Scheduler. You can set permissions and even have it run as Admin for those UAC enabled machines. –  Doltknuckle Jun 8 '10 at 21:30
    
the OP wants to run a script on logoff though, not logon. –  Om Nom Nom Jun 8 '10 at 22:20
    
To add a bit of context, im wanting to delete everything out of my downloads folder when i logoff. –  richzilla Jun 8 '10 at 22:35
    
In that case, why not just install Sandboxie and sandbox the downloads folder, then set it to clear on log off (99% sure thats an option) –  Hello71 Jun 9 '10 at 1:08
add comment

This may not be the type of solution you are looking for, but you can just use the batch script itself to shutdown or log off using the shutdown command.

C:\ >help shutdown Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f] [/m \computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

..snip..
/l         Log off. This cannot be used with /m or /d options.
/s         Shutdown the computer.
..snip..

Just put this command at the end of your script, maybe with a timer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.