How to schedule task execution when closing windows

How to schedule a task in Windows XP to start when windows are turned off. So I want to run a simple command line program that I wrote in C # every time I close windows. There seems to be no way in scheduled tasks to complete this task when my computer shuts down.

+79
windows-xp
Sep 19 '08 at 13:00
source share
10 answers

Run gpedit.msc (local policies)

Computer Configuration β†’ Windows Settings β†’ Scripts β†’ Shutdown β†’ Properties β†’ Add

+87
Sep 19 '08 at 13:05
source share

In addition to Dan Williams answer, if you want to add a Startup / Shutdown script, you need to look for Windows settings in the Computer Configuration section. If you want to add a Logon / Logoff script, you need to look for Windows settings in the User Configuration section.

So, to repeat what Dan said with this information,

To start / stop work:

  • Run gpedit.msc (local policies)
  • Computer Configuration β†’ Windows Settings β†’ Scripts β†’ Startup or Shutdown β†’ Properties β†’ Add

To log in / out:

  • Run gpedit.msc (local policies)
  • User Configuration β†’ Windows Settings β†’ Scripts β†’ Login or Logout> β†’ Properties β†’ Add



Source: http://technet.microsoft.com/en-us/library/cc739591(WS.10).aspx

+38
Sep 11 '13 at 17:25
source share

For those who prefer to use the task scheduler, you can schedule the task to start after restarting / shutting down by configuring the task to start after registering event 1074 in the system log in the event viewer. However, this is only suitable for very short tasks that will be performed while the system reboots / shuts down, which usually takes only a few seconds.

  • From the task scheduler:

    Begin the task: On an event
    Log: system
    Source: USER32
    EventID: 1074

  • From the command line:

    schtasks / create / tn "taskname" / tr "task file" / sc onevent / ec system / mo * [system / eventid = 1074]

Comment: The / ec option is available on Windows Vista and later. (thanks @ t2d)

Please note that the status of the task may be as follows:

The requested operation did not complete because the user was not logged on to the network. The specified service does not exist. (0x800704DD)

However, this does not mean that it did not start.

+31
Dec 06 '14 at 1:59
source share

A workaround may be to write a simple batch file to start the program, and then turn off the computer.

You can disconnect from the command line, so your script can be quite simple:

c:\directory\myProgram.exe C:\WINDOWS\system32\shutdown.exe -s -f -t 0 
+5
Sep 19 '08 at 13:06
source share

If you run GPEdit.MSC, you can go to Computer Configuration β†’ Windows Settings β†’ Scripts and add startup / shutdown scripts. It can be simple batch files or even full-screen EXE. You can also configure custom configurations for login and logout scripts in the same tool. This tool is not available in WIndows XP Home.

+4
Sep 19 '08 at 13:07
source share

Group Policy Editor is not mentioned in the message above. I used GPedit several times to complete the task when loading or shutting down. Following are Microsoft's instructions for accessing and maneuvering GPedit.

How to use Group Policy Editor to manage local computer policies in Windows XP

+4
Sep 19 '08 at 13:09
source share

You can run the batch file that invokes your program, check out the discussion here on how to do this: http://www.pcworld.com/article/115628/windows_tips_make_windows_start_and_stop_the_way_you_want.html

(from google search: launching the window schedule task on shutdown)

+1
Sep 19 '08 at 13:04
source share

What I can offer to do is create a shortcut for the .bat file (for example, on your desktop), and when you want to shut down your computer (and start the .bat file), click on the shortcut that you created. After that, edit the .bat file and add this line of code to the end or where necessary:

 c:\windows\system32\shutdown -s -f -t 00 

What does it mean?

  • Starts the shutdown process.
  • Displays a warning
  • Makes all running processes stop
  • Running immediately
+1
Aug 19 '17 at 11:00
source share

In Windows 10 Pro, a batch file can be registered; A workaround for registering cmd.exe and specifying the bat file as a parameter is not required. I just did this by registering a shutdown script and a startup (boot) script, and it worked.

+1
Nov 05 '18 at 3:54
source share

I also had to turn on β€œSpecify the maximum timeout for Group Policy scripts” and β€œShow instructions in shutdown scripts when they run” so that this worked for me, as I explain here .

0
Aug 13 '19 at 6:25
source share



All Articles