I try to automatically log the startup and shutdown times of my Windows Client (Windows 7 and newer) to a log file for later analysis.

Therefore I created a task in Task Scheduler which executes the following statement.

echo %date% %time% >>"C:\Temp\time_logging.log"

The triggers are "on system startup" and "on event" (for shutdown). As event I have chosen option "minimal/basic", source "eventlog" and event id "6006".

The startup is logged, but the shutdown isn't logged. The task is executed with "local service", the permission on the log file and folder is "local service" is "modify" (read, write, modify).

Do you have any clue what I'm doing wrong? Perhaps I choose an event, when the system has no more possibilities to write to file? But what event can I use for this scenario?

  • The Event Log "System" already contains all necessary information (events 12, 13 of Kernel-General). Accessing it isn’t that easy though. – Daniel B Apr 7 '17 at 12:21

The scheduled task is the right way to do it. For shutdown however, run gpedit.msc (Local Group/User Policies) and then go to Windows settings -> Scripts -> Shutdown -> Properties -> Add and set up a shutdown script.

  • That was way to easy ;-) Thank you! – StefanK Apr 10 '17 at 9:16

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.