How to schedule a task to run when shutting down windows
How do you schedule a task in Windows XP to run when you shutdown windows. Such that I want to run a simple command line program I wrote in c# everytime I shut down windows. There doesn't seem to be an option in scheduled tasks to perform this task when my computer shuts down.
windows-xp
add a comment |
How do you schedule a task in Windows XP to run when you shutdown windows. Such that I want to run a simple command line program I wrote in c# everytime I shut down windows. There doesn't seem to be an option in scheduled tasks to perform this task when my computer shuts down.
windows-xp
add a comment |
How do you schedule a task in Windows XP to run when you shutdown windows. Such that I want to run a simple command line program I wrote in c# everytime I shut down windows. There doesn't seem to be an option in scheduled tasks to perform this task when my computer shuts down.
windows-xp
How do you schedule a task in Windows XP to run when you shutdown windows. Such that I want to run a simple command line program I wrote in c# everytime I shut down windows. There doesn't seem to be an option in scheduled tasks to perform this task when my computer shuts down.
windows-xp
windows-xp
asked Sep 19 '08 at 13:00
CrippeobladeCrippeoblade
2,10042527
2,10042527
add a comment |
add a comment |
9 Answers
9
active
oldest
votes
Execute gpedit.msc (local Policies)
Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add
27
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I usedC:WindowsSystem32cmd.exe
as the Script Name and/C C:pathtobatchscript.bat
as the Script Parameters, it did.
– Dan Stevens
Jan 19 '13 at 16:41
3
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
how about restart?
– dangalg
Jun 19 '18 at 5:26
add a comment |
In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.
So to reiterate what Dan said with this information included,
For Startup/Shutdown:
- Run gpedit.msc (Local Policies)
Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add
For Logon/Logoff:
- Run gpedit.msc (Local Policies)
User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx
2
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
add a comment |
For those who prefer using the Task Scheduler, it's possible to schedule a task to run after a restart / shutdown has been initiated by setting the task to run after event 1074 in the System log in the Event Viewer has been logged.
However, it's only good for very short task, which will run as long as the system is restarting / shutting down, which is usually only a few seconds.
- From the Task Scheduler:
Begin the task: On an event
Log: System
Source: USER32
EventID: 1074 - From the command prompt:
schtasks /create /tn "taskname" /tr "task file" /sc onevent /ec system /mo *[system/eventid=1074]
Comment: the /ec option is available from Windows Vista and above. (thank you @t2d)
Please note that the task status can be:
The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (0x800704DD)
However, it doesn't mean that it didn't run.
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Please note, that the argument/ec system
does not exist, but it is called/ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4
– t2d
May 4 '16 at 12:42
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
1
There's a typo in the modifier in your example. It should be... /mo *[system/eventid=1074]
, not.../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
|
show 1 more comment
One workaround might be to write a simple batch file to run the program then shutdown the computer.
You can shut down from the command line -- so your script could be fairly simple:
c:directorymyProgram.exe
C:WINDOWSsystem32shutdown.exe -s -f -t 0
add a comment |
If you run GPEdit.MSC you can go to Computer Configuration -> Windows Settings -> Scripts, and add startup /shutdown scripts. These can be simple batch files, or even full blown EXEs. Also you can adjust user configurations for logon and logoff scripts in this same tool. This tool is not available in WIndows XP Home.
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
add a comment |
The Group Policy editor is not mentioned in the post above. I have used GPedit quite a few times to perform a task on bootup or shutdown. Here are Microsoft's instructions on how to access and maneuver GPedit.
How To Use the Group Policy Editor to Manage Local Computer Policy in Windows XP
add a comment |
You can run a batch file that calls your program, check out the discussion here for how to do it:
http://www.pcworld.com/article/115628/windows_tips_make_windows_start_and_stop_the_way_you_want.html
(from google search: windows schedule task run at shut down)
add a comment |
What I can suggest doing is creating a shortcut to the .bat file (for example on your desktop) and a when you want to shutdown your computer (and run the .bat file) click on the shortcut you created. After doing this, edit the .bat file and add this line of code to the end or where needed:
c:windowssystem32shutdown -s -f -t 00
What this does it is
- Runs the shutdown process
- Displays a alert
- Forces all running processes to stop
- Executes immediately
add a comment |
On Windows 10 Pro, the batch file can be registered; the workaround of registering cmd.exe and specifying the bat file as a param isn't needed. I just did this, registering both a shutdown script and a startup (boot) script, and it worked.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f101647%2fhow-to-schedule-a-task-to-run-when-shutting-down-windows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
Execute gpedit.msc (local Policies)
Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add
27
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I usedC:WindowsSystem32cmd.exe
as the Script Name and/C C:pathtobatchscript.bat
as the Script Parameters, it did.
– Dan Stevens
Jan 19 '13 at 16:41
3
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
how about restart?
– dangalg
Jun 19 '18 at 5:26
add a comment |
Execute gpedit.msc (local Policies)
Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add
27
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I usedC:WindowsSystem32cmd.exe
as the Script Name and/C C:pathtobatchscript.bat
as the Script Parameters, it did.
– Dan Stevens
Jan 19 '13 at 16:41
3
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
how about restart?
– dangalg
Jun 19 '18 at 5:26
add a comment |
Execute gpedit.msc (local Policies)
Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add
Execute gpedit.msc (local Policies)
Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add
edited Apr 24 '17 at 20:30
Fabian Röling
1501417
1501417
answered Sep 19 '08 at 13:05
Dan WilliamsDan Williams
3,62493145
3,62493145
27
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I usedC:WindowsSystem32cmd.exe
as the Script Name and/C C:pathtobatchscript.bat
as the Script Parameters, it did.
– Dan Stevens
Jan 19 '13 at 16:41
3
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
how about restart?
– dangalg
Jun 19 '18 at 5:26
add a comment |
27
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I usedC:WindowsSystem32cmd.exe
as the Script Name and/C C:pathtobatchscript.bat
as the Script Parameters, it did.
– Dan Stevens
Jan 19 '13 at 16:41
3
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
how about restart?
– dangalg
Jun 19 '18 at 5:26
27
27
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I used
C:WindowsSystem32cmd.exe
as the Script Name and /C C:pathtobatchscript.bat
as the Script Parameters, it did.– Dan Stevens
Jan 19 '13 at 16:41
If you want a batch script to run at Logoff, I found referencing the .bat file directly didn't work. However, if I used
C:WindowsSystem32cmd.exe
as the Script Name and /C C:pathtobatchscript.bat
as the Script Parameters, it did.– Dan Stevens
Jan 19 '13 at 16:41
3
3
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
WARINING: The group policy startup and shutdown scipts not executed, when using fastboot (enabled by default in windows 8 and up). In this case, only the restart or force shutdown (from command prompt) shut down really the computer. In all other cases (start menu shutdown), the computer kernel hibernated, and revieved on boot, and GPO startup and shutdown scipts are ignored.
– voji
Mar 26 '16 at 12:24
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
@voji: Is this true for Windows Server as well?
– sampathsris
Apr 24 '18 at 7:48
how about restart?
– dangalg
Jun 19 '18 at 5:26
how about restart?
– dangalg
Jun 19 '18 at 5:26
add a comment |
In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.
So to reiterate what Dan said with this information included,
For Startup/Shutdown:
- Run gpedit.msc (Local Policies)
Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add
For Logon/Logoff:
- Run gpedit.msc (Local Policies)
User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx
2
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
add a comment |
In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.
So to reiterate what Dan said with this information included,
For Startup/Shutdown:
- Run gpedit.msc (Local Policies)
Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add
For Logon/Logoff:
- Run gpedit.msc (Local Policies)
User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx
2
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
add a comment |
In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.
So to reiterate what Dan said with this information included,
For Startup/Shutdown:
- Run gpedit.msc (Local Policies)
Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add
For Logon/Logoff:
- Run gpedit.msc (Local Policies)
User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx
In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.
So to reiterate what Dan said with this information included,
For Startup/Shutdown:
- Run gpedit.msc (Local Policies)
Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add
For Logon/Logoff:
- Run gpedit.msc (Local Policies)
User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx
answered Sep 11 '13 at 17:25
Brett PenningsBrett Pennings
1,1381219
1,1381219
2
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
add a comment |
2
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
2
2
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
This is the better answer. When you open GPEditor it shows two nodes as you describe. Since both nodes have a Windows Settings option then the accepted answer is less clear than your answer. Thanks for the tip. Very helpful.
– Seth Spearman
Jul 1 '15 at 15:30
add a comment |
For those who prefer using the Task Scheduler, it's possible to schedule a task to run after a restart / shutdown has been initiated by setting the task to run after event 1074 in the System log in the Event Viewer has been logged.
However, it's only good for very short task, which will run as long as the system is restarting / shutting down, which is usually only a few seconds.
- From the Task Scheduler:
Begin the task: On an event
Log: System
Source: USER32
EventID: 1074 - From the command prompt:
schtasks /create /tn "taskname" /tr "task file" /sc onevent /ec system /mo *[system/eventid=1074]
Comment: the /ec option is available from Windows Vista and above. (thank you @t2d)
Please note that the task status can be:
The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (0x800704DD)
However, it doesn't mean that it didn't run.
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Please note, that the argument/ec system
does not exist, but it is called/ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4
– t2d
May 4 '16 at 12:42
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
1
There's a typo in the modifier in your example. It should be... /mo *[system/eventid=1074]
, not.../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
|
show 1 more comment
For those who prefer using the Task Scheduler, it's possible to schedule a task to run after a restart / shutdown has been initiated by setting the task to run after event 1074 in the System log in the Event Viewer has been logged.
However, it's only good for very short task, which will run as long as the system is restarting / shutting down, which is usually only a few seconds.
- From the Task Scheduler:
Begin the task: On an event
Log: System
Source: USER32
EventID: 1074 - From the command prompt:
schtasks /create /tn "taskname" /tr "task file" /sc onevent /ec system /mo *[system/eventid=1074]
Comment: the /ec option is available from Windows Vista and above. (thank you @t2d)
Please note that the task status can be:
The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (0x800704DD)
However, it doesn't mean that it didn't run.
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Please note, that the argument/ec system
does not exist, but it is called/ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4
– t2d
May 4 '16 at 12:42
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
1
There's a typo in the modifier in your example. It should be... /mo *[system/eventid=1074]
, not.../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
|
show 1 more comment
For those who prefer using the Task Scheduler, it's possible to schedule a task to run after a restart / shutdown has been initiated by setting the task to run after event 1074 in the System log in the Event Viewer has been logged.
However, it's only good for very short task, which will run as long as the system is restarting / shutting down, which is usually only a few seconds.
- From the Task Scheduler:
Begin the task: On an event
Log: System
Source: USER32
EventID: 1074 - From the command prompt:
schtasks /create /tn "taskname" /tr "task file" /sc onevent /ec system /mo *[system/eventid=1074]
Comment: the /ec option is available from Windows Vista and above. (thank you @t2d)
Please note that the task status can be:
The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (0x800704DD)
However, it doesn't mean that it didn't run.
For those who prefer using the Task Scheduler, it's possible to schedule a task to run after a restart / shutdown has been initiated by setting the task to run after event 1074 in the System log in the Event Viewer has been logged.
However, it's only good for very short task, which will run as long as the system is restarting / shutting down, which is usually only a few seconds.
- From the Task Scheduler:
Begin the task: On an event
Log: System
Source: USER32
EventID: 1074 - From the command prompt:
schtasks /create /tn "taskname" /tr "task file" /sc onevent /ec system /mo *[system/eventid=1074]
Comment: the /ec option is available from Windows Vista and above. (thank you @t2d)
Please note that the task status can be:
The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (0x800704DD)
However, it doesn't mean that it didn't run.
edited Nov 11 '18 at 8:48
answered Dec 6 '14 at 1:59
Oz EdriOz Edri
41147
41147
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Please note, that the argument/ec system
does not exist, but it is called/ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4
– t2d
May 4 '16 at 12:42
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
1
There's a typo in the modifier in your example. It should be... /mo *[system/eventid=1074]
, not.../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
|
show 1 more comment
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Please note, that the argument/ec system
does not exist, but it is called/ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4
– t2d
May 4 '16 at 12:42
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
1
There's a typo in the modifier in your example. It should be... /mo *[system/eventid=1074]
, not.../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Thanks for the tip! @Oz, Will this run on restart as well as shutdown? The case I'm trying to cover is Windows Update forces a restart...
– Erik Eidt
Jan 15 '15 at 1:13
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Yes, it is, since this event is logged on restart / shutdown.
– Oz Edri
Jan 16 '15 at 2:45
Please note, that the argument
/ec system
does not exist, but it is called /ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4– t2d
May 4 '16 at 12:42
Please note, that the argument
/ec system
does not exist, but it is called /ru system
. see support.microsoft.com/en-us/kb/814596#bookmark-4– t2d
May 4 '16 at 12:42
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
@t2d, while /ec exists in newer versions, /ru refers to a completely different thing. EC allows you to specify an event channel, while ru allows you to run as another user. Nonetheless thank you for your comment. I'll edit my post accordingly.
– Oz Edri
May 8 '16 at 9:03
1
1
There's a typo in the modifier in your example. It should be
... /mo *[system/eventid=1074]
, not .../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
There's a typo in the modifier in your example. It should be
... /mo *[system/eventid=1074]
, not .../mo *[system/evendid=1074]
– testworks
Nov 9 '18 at 2:45
|
show 1 more comment
One workaround might be to write a simple batch file to run the program then shutdown the computer.
You can shut down from the command line -- so your script could be fairly simple:
c:directorymyProgram.exe
C:WINDOWSsystem32shutdown.exe -s -f -t 0
add a comment |
One workaround might be to write a simple batch file to run the program then shutdown the computer.
You can shut down from the command line -- so your script could be fairly simple:
c:directorymyProgram.exe
C:WINDOWSsystem32shutdown.exe -s -f -t 0
add a comment |
One workaround might be to write a simple batch file to run the program then shutdown the computer.
You can shut down from the command line -- so your script could be fairly simple:
c:directorymyProgram.exe
C:WINDOWSsystem32shutdown.exe -s -f -t 0
One workaround might be to write a simple batch file to run the program then shutdown the computer.
You can shut down from the command line -- so your script could be fairly simple:
c:directorymyProgram.exe
C:WINDOWSsystem32shutdown.exe -s -f -t 0
answered Sep 19 '08 at 13:06
Neil NeymanNeil Neyman
1,7231320
1,7231320
add a comment |
add a comment |
If you run GPEdit.MSC you can go to Computer Configuration -> Windows Settings -> Scripts, and add startup /shutdown scripts. These can be simple batch files, or even full blown EXEs. Also you can adjust user configurations for logon and logoff scripts in this same tool. This tool is not available in WIndows XP Home.
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
add a comment |
If you run GPEdit.MSC you can go to Computer Configuration -> Windows Settings -> Scripts, and add startup /shutdown scripts. These can be simple batch files, or even full blown EXEs. Also you can adjust user configurations for logon and logoff scripts in this same tool. This tool is not available in WIndows XP Home.
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
add a comment |
If you run GPEdit.MSC you can go to Computer Configuration -> Windows Settings -> Scripts, and add startup /shutdown scripts. These can be simple batch files, or even full blown EXEs. Also you can adjust user configurations for logon and logoff scripts in this same tool. This tool is not available in WIndows XP Home.
If you run GPEdit.MSC you can go to Computer Configuration -> Windows Settings -> Scripts, and add startup /shutdown scripts. These can be simple batch files, or even full blown EXEs. Also you can adjust user configurations for logon and logoff scripts in this same tool. This tool is not available in WIndows XP Home.
answered Sep 19 '08 at 13:07
KibbeeKibbee
51.5k26133172
51.5k26133172
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
add a comment |
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
really useful to know you can run .EXEs, thanks!
– user533832
May 28 '13 at 12:38
add a comment |
The Group Policy editor is not mentioned in the post above. I have used GPedit quite a few times to perform a task on bootup or shutdown. Here are Microsoft's instructions on how to access and maneuver GPedit.
How To Use the Group Policy Editor to Manage Local Computer Policy in Windows XP
add a comment |
The Group Policy editor is not mentioned in the post above. I have used GPedit quite a few times to perform a task on bootup or shutdown. Here are Microsoft's instructions on how to access and maneuver GPedit.
How To Use the Group Policy Editor to Manage Local Computer Policy in Windows XP
add a comment |
The Group Policy editor is not mentioned in the post above. I have used GPedit quite a few times to perform a task on bootup or shutdown. Here are Microsoft's instructions on how to access and maneuver GPedit.
How To Use the Group Policy Editor to Manage Local Computer Policy in Windows XP
The Group Policy editor is not mentioned in the post above. I have used GPedit quite a few times to perform a task on bootup or shutdown. Here are Microsoft's instructions on how to access and maneuver GPedit.
How To Use the Group Policy Editor to Manage Local Computer Policy in Windows XP
edited Oct 9 '12 at 12:11
meagar♦
178k29272288
178k29272288
answered Sep 19 '08 at 13:09
Michael RunyonMichael Runyon
6891912
6891912
add a comment |
add a comment |
You can run a batch file that calls your program, check out the discussion here for how to do it:
http://www.pcworld.com/article/115628/windows_tips_make_windows_start_and_stop_the_way_you_want.html
(from google search: windows schedule task run at shut down)
add a comment |
You can run a batch file that calls your program, check out the discussion here for how to do it:
http://www.pcworld.com/article/115628/windows_tips_make_windows_start_and_stop_the_way_you_want.html
(from google search: windows schedule task run at shut down)
add a comment |
You can run a batch file that calls your program, check out the discussion here for how to do it:
http://www.pcworld.com/article/115628/windows_tips_make_windows_start_and_stop_the_way_you_want.html
(from google search: windows schedule task run at shut down)
You can run a batch file that calls your program, check out the discussion here for how to do it:
http://www.pcworld.com/article/115628/windows_tips_make_windows_start_and_stop_the_way_you_want.html
(from google search: windows schedule task run at shut down)
answered Sep 19 '08 at 13:04
devinmooredevinmoore
2,49721614
2,49721614
add a comment |
add a comment |
What I can suggest doing is creating a shortcut to the .bat file (for example on your desktop) and a when you want to shutdown your computer (and run the .bat file) click on the shortcut you created. After doing this, edit the .bat file and add this line of code to the end or where needed:
c:windowssystem32shutdown -s -f -t 00
What this does it is
- Runs the shutdown process
- Displays a alert
- Forces all running processes to stop
- Executes immediately
add a comment |
What I can suggest doing is creating a shortcut to the .bat file (for example on your desktop) and a when you want to shutdown your computer (and run the .bat file) click on the shortcut you created. After doing this, edit the .bat file and add this line of code to the end or where needed:
c:windowssystem32shutdown -s -f -t 00
What this does it is
- Runs the shutdown process
- Displays a alert
- Forces all running processes to stop
- Executes immediately
add a comment |
What I can suggest doing is creating a shortcut to the .bat file (for example on your desktop) and a when you want to shutdown your computer (and run the .bat file) click on the shortcut you created. After doing this, edit the .bat file and add this line of code to the end or where needed:
c:windowssystem32shutdown -s -f -t 00
What this does it is
- Runs the shutdown process
- Displays a alert
- Forces all running processes to stop
- Executes immediately
What I can suggest doing is creating a shortcut to the .bat file (for example on your desktop) and a when you want to shutdown your computer (and run the .bat file) click on the shortcut you created. After doing this, edit the .bat file and add this line of code to the end or where needed:
c:windowssystem32shutdown -s -f -t 00
What this does it is
- Runs the shutdown process
- Displays a alert
- Forces all running processes to stop
- Executes immediately
answered Aug 19 '17 at 11:00
Matthew SmithMatthew Smith
254218
254218
add a comment |
add a comment |
On Windows 10 Pro, the batch file can be registered; the workaround of registering cmd.exe and specifying the bat file as a param isn't needed. I just did this, registering both a shutdown script and a startup (boot) script, and it worked.
add a comment |
On Windows 10 Pro, the batch file can be registered; the workaround of registering cmd.exe and specifying the bat file as a param isn't needed. I just did this, registering both a shutdown script and a startup (boot) script, and it worked.
add a comment |
On Windows 10 Pro, the batch file can be registered; the workaround of registering cmd.exe and specifying the bat file as a param isn't needed. I just did this, registering both a shutdown script and a startup (boot) script, and it worked.
On Windows 10 Pro, the batch file can be registered; the workaround of registering cmd.exe and specifying the bat file as a param isn't needed. I just did this, registering both a shutdown script and a startup (boot) script, and it worked.
answered Nov 5 '18 at 3:54
Wo'O IdeafarmWo'O Ideafarm
112
112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f101647%2fhow-to-schedule-a-task-to-run-when-shutting-down-windows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown