Page 1 of 1

Want to run on local machine as different user but seems that windows has limitations on running as different user on lo

Posted: 18 Nov 2021 04:08
by batchnewbie
Dear all,

My Objective: run a scheduled task on the local machine as the designed scheduled user, i.e. cambridge in this case

Code: Select all


SCHTASKS /Run /U rman /P cambridge@123 /TN delete_expired_backup /HRESULT

ERROR: Invalid syntax. Cannot specify user name without specifying system name.
Type "SCHTASKS /?" for usage.

SCHTASKS /Run /S system /U rman /P cambridge@123 /TN delete_expired_backup /HRESULT

C:\Users\lhung>SCHTASKS /Run /S system /U rman /P cambridge@123 /TN delete_expired_backup /HRESULT
ERROR: The request is not supported

SCHTASKS /Run /S localhost /U rman /P cambridge@123 /TN delete_expired_backup /HRESULT
ERROR: User credentials are not allowed on the local machine.

however I'm able to run as myself which is not what I want

Code: Select all

SCHTASKS /Run /TN delete_expired_backup /HRESULT

SUCCESS: Attempted to run the scheduled task "delete_expired_backup_copy"

cambridge is a local user account. it is not a domain user.

many thanks in advance!

Best Regards

Re: Want to run on local machine as different user but seems that windows has limitations on running as different user o

Posted: 02 Dec 2021 17:40
by Eureka!
That is not how scheduled tasks work.

When configuring a scheduled task, you also define the usercredentials that will be used to run the task (the Security options on the General tab).

When you execute a command SCHTASKS /RUN .. , you need to "prove that you are worthy" to kick off that scheduled task.
(Otherwise regular useraccounts could execute destructive admin tasks, for example)

In most cases that means that you need to be an administrator. But that task will still run under the Security options of that task.