This Stack Overflow question suggests a command which looks as if it should work, but it doesn't (that answer is deleted now, though):
Single line command for Run as a different user on Window 7 that contains a password also
The command would be:
echo PaSsWoRd | runas /user:Administrator cmd
However it says:
unknown user name or bad password.
The details are definitely correct though. For example, if I was to run:
runas /user:Administrator
...and on the next line, if I typed in PaSsWoRd
, it would work no problem.
runas /user:Administrator “cmd” < “C:\pass.txt”
– Contiguousrunas /savecred ...
, it will prompt for password once, then remember it. (see the password storagerundll32.exe keymgr.dll,KRShowKeyMgr
) – Blinny/savecred
doesn't work with/netonly
though. Most solutions I tried do not work. I didn't try psexec, as it's rather heavyweight for me, but I had success with the RunAs module for powershell and the built-in Windows "Credentials manager". – Williwaw