How to Keep Track of When You Work Using a Scheduled Task

Ads by Google

During the day, I work as a web developer. To get paid I need to complete a time-sheet. Some weeks I’ll get to Friday and realize, “Hey! I forgot to fill in my time-sheet, and I can’t remember what hours I did this week!.” I’m sure office-goers like me can relate to this situation. :)

In this guide I’ll show you how I resolved this problem, by creating a scheduled task that will log the date and time when I login or lock my computer. This can help every one, including those who work from home (like this site’s editor), to accurately track the time spent in front of computer every day. The trick is Windows only.

Part One: Creating the script

Step 1. Create a folder.

Create login folder

Step 2. Create a new text file in that folder and name it login.bat.

To do this right a blank space in the folder and select New -> Text Document.

Create new text document

Name it login.bat. (Make sure it is not named login.bat.txt)

Rename to login.bat

Step 3. Open the text file and copy and paste the following code into it.

@echo off
set datecode=%date:~-4%-%date:~7,2%-%date:~4,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
if "%1"=="i" echo %datecode% - Logged in >> C:\!Scripts\Login\login.txt
if "%1"=="o" echo %datecode% - Locked computer >> C:\!Scripts\Login\login.txt

Save it!

Important Note: If you want your log file to appear somewhere different to mine, then make sure you update the path in the script.

Part Two: Creating the login task

Step 1. Open Task Scheduler, by going Start -> Run (WIN+R) and typing taskschd.msc in the prompt that appears.

Open task scheduler

Step 2. Select Create Task… from the actions on the right hand side.

Create task

Step 3. Enter a task name like Log the login date and time.

Enter login task name

Step 4. Click on the Triggers tab and add a new trigger. Select:

  • Begin the task: At log on
  • Specific user: This should be your Windows account

Login trigger

Click OK to add the trigger.

Step 5. Add another trigger except this time select Begin the task: On workstation unlock.

Ads by Google

Unlock trigger

Click OK to add the trigger.

Step 6. Click on the Actions tab. Add a new action and point it to your login script with the argument i.

Add login action

Click OK to add the action.

Step 7. (Optional – Only required if you are using a laptop) Click on the Conditions tab and uncheck the box that says Start the task only if the computer is on AC power.

Set power options

Click on OK to create the task.

Part Three: Creating the lock task

Step 1. In Task Scheduler, select Create Task… from the actions on the right hand side.

Create task

Step 2. Enter a task name like Log the lock date and time.

Create lock task name

Step 3. Click on the Triggers tab and add a new trigger. Select:

  • Begin the task: On workstation lock
  • Specific user: This should be your Windows account

Lock trigger

Click OK to add the trigger.

Step 4. Click on the Actions tab. Add a new action and point it to your login script with the argument o.

Add lock action

Click OK to add the action.

Step 5. (Optional – Only required if you are using a laptop) Click on the Conditions tab and uncheck the box that says Start the task only if the computer is on AC power.

Set power options

Click on OK to create the task.

Part Four: Testing that everything is working as expected

Your work is now complete. You just need to test that everything is working as expected. Just lock your computer by hitting WIN+L and log back in. If you followed the instructions properly, you should now have a file called login.txt in the same folder as your script. This file should contain a log of each time you log in and out of your computer.

Log file

Lastly, if you want to be able to access this log file quickly, you may want to follow our guide on how to use keywords to launch almost anything quickly in Windows.

Before You Go...

Just wanted to let you know that we've got a special eBook on Google Chrome browser, called The Ultimate Chrome Productivity Guide where we show you how to master Google Chrome to make the most out of it. Make sure you buy it because it is worth much more than the price we're offering it for.

Get Guiding Tech articles delivered to your inbox.

Also get a free ebook when you subscribe.

We will never share your address. Unsubscribe at any time.



  • Pingback: Awesome Links #35: Time Tracking, Android Apps, Mobile Priority Inbox - Legit Way To Make Money()

  • Gilbert

    Time management is essential at work it can help you do more work without wasting time. I manage time with a bit of self discipline which helps me manage my task effectively and at the same time finish work at a designated time. I also use a time management tool that tracks time accurately. I also list my entire task on it, organize it depends on the priority level and set an amount of time to do each task. Using this tool I would say that I am more productive than before.

  • josh_fuggle

    Nice post, very helpful.

  • Techless79

    My text file (login.txt) did not appear with the log…. can you help troubleshoot? I followed your directions twice but with no success….

  • Pingback: How to Effectively Measure the Amount Of Work You Actually Do()

  • Anon

    The text file appeared but it just showed the thing i copied. it didnt display the time i locked/logged in. I’ve repeated the process thrice already but same problem still