user7637980
user7637980

Reputation:

Runas command Access denied

I want to run a program from startup by a batch file in startup folder, the file says this:

runas.exe /savecred /"user:pedro burgos" "%cd%\test.bat"

But, the problem is that when I run this and enter my password, it says Error 5: Access denied

Can anyone help me pls?

Upvotes: 4

Views: 8834

Answers (4)

Visitor
Visitor

Reputation: 11

Had the same issue as you on Server 2019, secondary logon service on manual. Your initial answer seemed to be the solution but it wasn't. On server 2019 the secondary logon service is on manual by default and will start automatic if you are using a run as command.

The answer was as is upgraded the server 2019 edition that the local system account didn't have the correct rights to engage with the secondary logon service.

Resolved the issue with this MS article (article is for server 2012) Start CMD as administrator;

sc sdset seclogon D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWRPDTLOCRRC;;;IU)(A;;CCLCSWDTLOCRRC;;;SU)(A;;CCLCSWRPDTLOCRRC;;;AU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)

Upvotes: 1

Ate Somebits
Ate Somebits

Reputation: 309

Found this in another forum.

Feel like a dumbass now, but do use caution, and get more info.

The runas command depends on the Secondary Logon service. On my system, it is by default set to manual, and it is not activated.

AFAIK, this is a legacy feature, so that is probably the reason why it is not running.

EDIT: It's legacy, because this command predates UAC; MS would like you to use UAC instead of runas, which is safer; you can trigger a UAC prompt by calling scripts in PowerShell with -Verb RunAs argument

Upvotes: 5

FukingLost
FukingLost

Reputation: 13

Make sure user "pedro burgos" actually has access to that directory. For example, one user can't just access other user's directories. You can test this theory by moving the script to something like C:\temp

Upvotes: 0

user7452368
user7452368

Reputation:

try this runas.exe /savecred /user:"pedro burgos" "%cd%\test.bat"

Upvotes: 0

Related Questions