1
I want to create a batch file that creates a scheduled task to run a .cmd file when a specific user logons. So far I've come up with this:
@echo off
schtasks /CREATE /RU %username% /TN "TaskName" /TR "C:\folder\file.cmd" ^
/SC ONLOGON /DELAY 0000:10 /IT /RL highest
PAUSE
which creates the task just fine, but when looking at the trigger properties the option 'Any user' is checked instead of 'Specific user'. I've tried looking to solutions everywhere but everything seemed to point to using /IT
with /RU
.
Also as a side question, do I need to include /PU
in the script? I plan on running the batch file on multiple machines and feel that it will be a security/implementation issue to ask people for their passwords.
Keep in mind, though, that while this is correct, that the task will run when a different user is logged on if the originally specified user is still logged on from a previous session. Where this is not the case with the GUI's "at log on of a specific user" option. – Daniel Goudie – 2017-05-08T18:46:23.903