F5F Stay Refreshed Software Operating Systems Set the batch file to execute just before shutdown, avoiding a restart.

Set the batch file to execute just before shutdown, avoiding a restart.

Set the batch file to execute just before shutdown, avoiding a restart.

A
alex68
Junior Member
36
08-04-2023, 03:12 AM
#1
I’m trying to set up a task that executes a batch file only when the computer powers off, not when it restarts. ChatGPT has offered some guidance, but I want to understand the details. Is this feasible? If yes, what steps should I follow? Thanks ahead!
A
alex68
08-04-2023, 03:12 AM #1

I’m trying to set up a task that executes a batch file only when the computer powers off, not when it restarts. ChatGPT has offered some guidance, but I want to understand the details. Is this feasible? If yes, what steps should I follow? Thanks ahead!

S
SSGSS_54
Member
85
08-04-2023, 04:28 AM
#2
When you open the batch file yourself, add the shutdown command at the finish. For example, shutdown /s /t 0 attempts to power off your computer right away.
S
SSGSS_54
08-04-2023, 04:28 AM #2

When you open the batch file yourself, add the shutdown command at the finish. For example, shutdown /s /t 0 attempts to power off your computer right away.

D
Dustroier
Junior Member
9
08-08-2023, 04:36 AM
#3
It would be useful if you could tell us what steps you've taken so far and the result you received. The issue arises because running a script during shutdown causes the system to stop, leaving little time to act before the script is terminated. You might consider a script that prevents shutdown, performs necessary tasks, and then reschedules the shutdown.
D
Dustroier
08-08-2023, 04:36 AM #3

It would be useful if you could tell us what steps you've taken so far and the result you received. The issue arises because running a script during shutdown causes the system to stop, leaving little time to act before the script is terminated. You might consider a script that prevents shutdown, performs necessary tasks, and then reschedules the shutdown.

F
Freakiiianyx3
Senior Member
694
08-15-2023, 10:41 PM
#4
Create a simple script that performs an action, followed by a shutdown command using a different shortcut each time.
F
Freakiiianyx3
08-15-2023, 10:41 PM #4

Create a simple script that performs an action, followed by a shutdown command using a different shortcut each time.

M
Mobarley7
Member
186
08-16-2023, 02:51 AM
#5
Yes, you're right. It's often not the most practical choice to terminate via the script instead of letting it run normally.
M
Mobarley7
08-16-2023, 02:51 AM #5

Yes, you're right. It's often not the most practical choice to terminate via the script instead of letting it run normally.

N
NastyBastrd
Member
186
08-17-2023, 05:00 AM
#6
You won’t be able to catch a shutdown signal. The safest method is to delete the shutdown choice from the power settings in the Start Menu and include a command at the end of your script to trigger the shutdown (shutdown /sg /t 0 /f)
N
NastyBastrd
08-17-2023, 05:00 AM #6

You won’t be able to catch a shutdown signal. The safest method is to delete the shutdown choice from the power settings in the Start Menu and include a command at the end of your script to trigger the shutdown (shutdown /sg /t 0 /f)

T
TheCryzzHD
Junior Member
44
08-30-2023, 06:45 PM
#7
I propose an alternative approach: replace the shutdown button connection directly to the motherboard with some external hardware. Create a device that mimics a specific key (such as the Lenovo Vantage button) or triggers a complicated hotkey sequence you won’t use daily. Set up a service that runs your batch file when it receives a command.
T
TheCryzzHD
08-30-2023, 06:45 PM #7

I propose an alternative approach: replace the shutdown button connection directly to the motherboard with some external hardware. Create a device that mimics a specific key (such as the Lenovo Vantage button) or triggers a complicated hotkey sequence you won’t use daily. Set up a service that runs your batch file when it receives a command.