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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batchnewbie
Posts: 2
Joined: 08 Nov 2021 19:35

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

#1 Post by batchnewbie » 18 Nov 2021 04:08

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

Eureka!
Posts: 125
Joined: 25 Jul 2019 18:25

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

#2 Post by Eureka! » 02 Dec 2021 17:40

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.

Post Reply