Runas command Access denied

Viewed 5260

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?

4 Answers

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

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

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)
Related