How to run the "runas" command without writing the password

5

1

I need to run the "runas" command for log on automatically an Application User, on an Active Directory. Then I need run an executable file.

Can I do this in some way or work around to do not type the password?

MacGyver

Posted 2012-01-05T18:52:05.730

Reputation: 404

Is this batch file running at startup or logon? A bit more info may help get an answer. – Dave M – 2012-01-05T19:44:23.230

Answers

5

Summary

Runas might not be supported but you could use a freeware utility CPAU http://www.joeware.net/freetools/tools/cpau/index.htm

This utility will allow you to launch an application using a different set of credentials then the current user. The neat advantage with CPAU over runas is that you can specify both the username and password at runtime. With the runas command you'd first have to configure a cached credential or be prompted for password at each run.

Examples

Using CPAU to launch iexplore.exe you could use a statement like:

from cmd prompt:

cd <path to cpau> -d
cpau.exe  /u domain\username  /p 123456  /ex "c:\Program Files (x86)\Internet Explorer\iexplore.exe" /lwp

from powershell script:

cd <path to cpau> -d
invoke-expression "cpau.exe  /u 'domain\username'  /p '123456'  /ex 'c:\Program Files (x86)\Internet Explorer\iexplore.exe' /lwp"

/lwp means to Load With Profile, and can be replaced with /lwop Load Without Profile

Ro Yo Mi

Posted 2012-01-05T18:52:05.730

Reputation: 347

I do this: Open cmd as Administrator. Then I use command cpau -u domain\username -p xxx -ex "C:\windows\explorer.exe " but I get error *Windows cannot access the specificed device, path, or file. Yoy may not have the appropiate permissions to access the item.*

And its appears another dialog with title *shell:::{52205fd8-5dfb-447d-801a-d0b52f2e83e1}* and the same error message. – Kiquenet – 2015-02-10T15:27:27.143

It's probably because you didn't install the utility properly. – Anup Kattel – 2015-02-13T03:31:28.857

1

what about RUNASSPC? You create an certificate for needed program, the password et. is saved as encrypted file so for example guest user can run only the particular software as administrator. RUNASSPC window

and the license:

RunasSpc is free for private use. For companies we deliver a licensed version of runasspc, registered to the enterprise`s name..

Juhele

Posted 2012-01-05T18:52:05.730

Reputation: 2 297

1For domains it need registration – MacGyver – 2012-01-06T14:32:02.240

1

Use option /savecred, then the password will be saved when you have typed it and not asked for again. (You can can use "runas /?" to get help for this command.)

Sempervivum

Posted 2012-01-05T18:52:05.730

Reputation: 111

0

I found a solution for this. In my case I was launching a scheduled task at login. Below is the command I used to launch the elevated powershell window without a password prompt:

powershell.exe "Start-Process powershell -verb runAs"

I had it set to run with highest privileges.

John Forbes

Posted 2012-01-05T18:52:05.730

Reputation: 131