Solved

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

Posted on 2011-03-01
6
547 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
learn programming 8 43
Do Wend Macro not working 22 36
active directory 6 14
Assignment from incompatible pointer type? 2 11
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

820 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