Get username logging on from task scheduler

task-scheduler

I'm using Windows Server 2008 task scheduler to run a task when a user logs on, but I would like some way of the task being able to access the name of the user who is logging on. I don't know if there is an environment variable I can access in the task or I can add something in as a parameter when the task runs?

Best Answer

Edit:

You might want to attach the trigger of your task to a certain event so you can reference the event's data. I can't exactly tell you what event you would want to attach the trigger to (e.g. is it only remote logins you're interested in, etc.), but I think this might very well be what you're looking for.

Hope it helps!

Original answer:

You might want to have a look at this handy list, which should give you an idea. In the most simple of cases %USERNAME% might just be what you need (e.g. in a batch file you might run).