Solved

run a .bat or script file only on restart not shutdown

Posted on 2011-03-01
6
546 Views
Last Modified: 2012-05-11
is there a way to run a .bat file or script only on a restart vs a shutdown command?
gpmc i believe only lets me apply it to a shutdown or restart, as i only want the it to run if a user or a wsus update tells the system to restart. it must be hidden with no user interaction.
i can not run any freeware or what not.
Vista SP2 Enterprise

or a similar solution!
Thanks,
0
Comment
Question by:DCSIMVT
  • 2
6 Comments
 
LVL 27

Expert Comment

by:Steve
ID: 35011885
You're going to struggle on that one without some form of script on the PCs. AD & group policies cannot distinguish between a shutdown and a restart.

There are ways to work it out on startup (parsing the event logs for example) but nothing as simple as you are hoping for.
0
 
LVL 14

Accepted Solution

by:
BigBadWolf_000 earned 250 total points
ID: 35012053
A restart is a shutdown and a startup...so no not from the system

But if you want a restart to launch a script before shut down you would have to launch the the script to do the restart with the shutdown /r parameter.

0
 

Author Comment

by:DCSIMVT
ID: 35278283
i have not found any answer,
please delete
0
 
LVL 27

Assisted Solution

by:Steve
Steve earned 250 total points
ID: 35308786
you have got an answer to your question: No.

Your requirement of it being hidden from users view and using 'no freeware or what not' means the answer is no.
It may not be the answer you wanted but it is still an answer to your original question.

The reason is that PCs cannot distinguish between a restart and a shutdown by default.
It may be possible to create a VB script or batch file that could parse the event log to work out how long it was turned off for and assume its a restart if the time is particularly short, but this may use freeware utils to parse the event logs, which you have ruled out.

It may be possible to use a freeware util to do this without the script, but your question specifically prohibits this.

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question