Solved

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

Posted on 2011-03-01
6
544 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
Comment Utility
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
Comment Utility
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
Comment Utility
i have not found any answer,
please delete
0
 
LVL 27

Assisted Solution

by:Steve
Steve earned 250 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now