5
I need to run batch scripts at shutdown of Windows 10 home edition, both on manual restarts and on automatic restarts due to Windows automatic updates. This needs to work while no users are logged in too. So far I've tried:
- Scheduled Task at eventid 1047 (discarded, won't wait till my script is over).
- Manually adding Group Policy shutdown scripts to registry and to C:\WINDOWS\SYSTEM32\GroupPolicy (discarded, won't run since it looks like the functionality is disabled by restraints imposed by the Windows edition.)
- Third party software. Weird enough, I couldn't find any free tool that would run as a service and allow me to add .bat files to be run at system (or service) shutdown.
- I tried AutoHotkey + NSSM [The Non-Sucking Service Manager] as a custom service, but AutoHotkey's events wouldn't trigger every time.
I'm quite disenchanted with this limitation.
Any ideas?
Edit1: Take into account Windows automatic updates.
Edit2: This needs to work while no users are logged in too.
Edit4: I'm waiting for the next Windows automatic restart due to a Windows update to see if running shutdown -a
at the beginning of the batch file and then shutdown -s
at the end within a scheduled task at shutdown event approach works.
Edit5: Bummer, it didn't work. The scheduled task did not start: Error: "Shutdown in progress". I guess my only hope is a third-party tool.
6You can add shutdown -a to the beginning of your batch file then shutdown -s at the end. This will abort the shutdown and let your process execute then resume the shutdown when it's done. – Neelix – 2017-04-21T21:22:40.573
@Neelix, so far your proposed solution works with shutdowns triggered by
shutdown -s
but not by the Start menu's Power button. I'll have to wait till next Windows automatic update restart to see if it will work for me. I'll post the results back. Thanks. – B. Gray – 2017-04-23T02:03:17.937What sort of stuff are you trying to do? It would help to know the context in which you are trying to execute something. Also, have you tried LOCAL group policy editor and putting in a test script that copies a file, in order to confirm that you are implementing the script correctly? – Xalorous – 2017-04-27T16:40:31.933
I need to store a value in a .db file upon shutdown of the system. It is a monitoring program which needs this specific information to log stuff accurately. gpedit.msc is not present in Windows home edition. It seems this whole functionality is stripped off from the edition. – B. Gray – 2017-04-29T13:22:06.410
Given that it sounds like you're trying to do something at work with a version of Windows designed for home use then (assuming the presence of
gpedit.msc
will resolve your issue) can you persuade your company to pay $99 to upgrade from Home to Pro? – Richard – 2017-11-27T15:37:52.287@Richard Not at work. This PC has been running the same home edition of Windows 7 / 10 since 2010 with good results. So after almost 8 years of uptime I just regard such upgrade as untimely . Thanks for asking. – B. Gray – 2017-11-29T12:38:07.960
Could you explain how you achieved case 1? I can not seem to understand how to use the task scheduler to run a batch at logout/shutdown. – Kajsa – 2018-04-04T16:05:13.373