Solved

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

Posted on 2011-03-01
6
549 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

717 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