# Task Scheduler Batch file



## jgunning (Sep 10, 2012)

Hi all,

Looking for some help.Im creating a batch file to run for different users to add a scheduled task. HOWEVER - the whole thing works great and has done for some time.But after i run the batch file on each machine (different users) i have to go into the security options and change the user the task runs in to the unique user of that machine. Is there a way to use the batch file to pull the account name of the machine (or computer name) and use that as the user the task runs in?


Thanks =)


----------



## Steevo (Sep 10, 2012)

C:\Users\Username\Desktop


Make it hidden and run from user desktop, extract "Username" by writing it to a text file.


----------



## jgunning (Sep 10, 2012)

I get the first bit, but what do you mean by "extract "Username" by writing it to a text file."
I want to automate the whole process essentially. No matter what user i am logged in as, it will add the task and customise it to run only when logged in as the current user.


----------



## Steevo (Sep 10, 2012)

if you launch a batch file as any user it will launch in that users account.

Create a batch that runs "dir" command and outputs it to a text file, that will be in said users account, and if it exists already it just reads the username from teh text file.

I will tell you what you need to know, but I'm not doing it for you.


----------

