Home » Questions » Computers [ Ask a new question ]

Automatically run a script when I log on to Windows

Automatically run a script when I log on to Windows

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

Asked by: Guest | Views: 459
Total answers/comments: 3
Guest [Entry]

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

Start > Administrative Tools > Task Scheduler
left pane: select Task Scheduler Library
right pane: click Create Task... (NOTE: this is the only way to get the correct trigger)
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"
Guest [Entry]

"The simplest way I can think of would be to put this in a .bat file in your startup folder.

A more complicated way would be to add the batch file to the registry in the

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

registry key."
Guest [Entry]

No need! Windows already has a mechanism to log this for you in the event log. The event ID is 4624 (528 on pre-Vista systems).