Run program automatically as a specific user

1

So I know, that I could just create a shortcut with RunAs but I was wondering, whether it would be possible to pass the password already as a parameter to the script, so I do not have to type it in all the time.

Any advise?

Thanks!

arvenyon

Posted 2017-12-07T07:36:11.150

Reputation: 45

Does this solution works for you?

– berserck – 2017-12-07T08:32:03.523

@berserck Not quite what im searching for, I'm currently trying out cpau and runasspc – arvenyon – 2017-12-07T08:54:26.743

Answers

2

Rather than putting the password in the batch file you can use the /savecred switch to get it to save your password for you after you enter it.

It will mean that you can always run any program as that user in future, but it is slightly more secure than leaving your password in plaintext in a batch file.


runas cannot be supplied a password, it was specifically written to forbid accepting a password on the command line for security reasons.

An alternative program might be cpau which will accept a password.

Mokubai

Posted 2017-12-07T07:36:11.150

Reputation: 64 434

That's a good idea, but not exactly what I need. It should save the credentials only for this specific program... – arvenyon – 2017-12-07T07:52:00.083

Apparently they decided that runas should never do that for the exact reason I've stated. I've linked to another answer that provides an alternative. – Mokubai – 2017-12-07T08:01:42.170

Thanks alot for your help! I'm using now cpau, as you mentioned above, it works now perfectly. – arvenyon – 2017-12-07T09:06:05.730