Automatically run a script when I log on to Windows

Hallgrim

How can I automatically run a script when I log on to Windows?

I'd like to run something like this whenever I log into my computer:

echo %USERNAME% logged on at %DATE% %TIME% >> log.txt

A bonus would be to be able to run the same script whenever I unlock the screen saver as well.

Jeff

You can create a scheduled task that will run when your computer is unlocked:

  1. Start > Administrative Tools > Task Scheduler
  2. left pane: select Task Scheduler Library
  3. right pane: click Create Task... (NOTE: this is the only way to get the correct trigger)
  4. in the Create Task dialog:
    • General tab -- provide a name for your task
    • Triggers tab -- click New... and select On workstation unlock
    • Action tab -- click New... and click Browse... to locate your script
    • Conditions tab -- uncheck Start the task only if the computer is on AC power

Also, I tweaked the path in the script to read

echo %USERNAME% logged on at %DATE% %TIME% >> %USERPROFILE%\log.txt

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why is code inside of classes executed automatically when I run a ruby script?

How can I run script automatically after Docker container startup

Python 3.6 is not default when I run a script

Run python script automatically every week (windows)

Both Chrome & emulator is closing automatically when I run my protractor script which I wrote for mobile Site(Angular)

Powershell Error when run the script automatically

How to schedule the node js script to run automatically on windows?

Is there a way to automatically run an initialization script when starting Windows 10 Powershell?

How can I automatically log out users from a Windows machine?

terminal closes when I run shell script

NaN when I run this script

Run command / script when program starts in Windows

How can i run php file automatically in windows7

What files are run when I log into the desktop?

How do I automatically run a shell script at start up?

Having a bash script run at startup and display the results when I log in

How can I run a PHP Script automatically Daily in WAMP / Windows Environment?

How do I make the script to run automatically when tun0 interface up/down events?

Why does this script output corrupt files when run automatically with crontab?

How can I automatically run a command when I log out?

Roslyn crashes when I try to run a script

How to create a console application to run automatically when windows start

Lua: I get error when I try to run a script in Windows

Automatically open a virtual environment when calling a python script in Windows

How do I run a python script at specific time in a day automatically?

Run automatically Script when GitHub Issue has been closed

How can i run script in firebase automatically

it gives an error when i run a SQL script

How to generate a log file of the windows prompt when I run a bat file