I tried to execute notepad from cmd using the following command-
runas /noprofile /user:<username>@<ip> notepadThen I got this output where I was asked to enter my password
Enter the password for <username>@<ip>:After entering my password (which is correct), I got this output-
Attempting to start notepad as user "<username>@<ip>" ...
RUNAS ERROR: Unable to run - notepad
1326: Logon failure: unknown user name or bad password.Any idea why I got the above output? I'm actually a dummy when it comes to programming and scripting in windows terminals. Also, is it possible for me to avoid the interaction part where I'm asked for password and enter it as part of the runas command itself?
4 Answers
The "user" parameter expects user credentials that consist of a user name and an (optional) domain name, you can't use an IP address as you are attempting.
From runas /?:
<UserName> should be in form USER@DOMAIN or DOMAIN\USERIf you have no domain, you can use the target computer's name so that it knows to look there for the credential store to check against.
As to including the password so you don't have to type it, no you can't do that, as it is considered insecure.
Perhaps check out these SU questions related to dealing with that:
- How to run the "runas" command without writing the password
- Run program as different, password protected user in Win 7 wo/ PW prompt
If you want to specify username and password on command-line you can try PsExec from Syinternals/Microsoft.
As I am not allowed to comment yet... Is this an Active Directory environment , or do you try to access a User or Group from an other computer.
If it's an AD environment i suggest NOT to use an IP but the domain name (NetBios name is also OK)
I just tried this out on my own an it worked out. (result is german)
C:\Users\user>runas /noprofile /user: notepad
Geben Sie das Kennwort für "" ein:
Es wird versucht, notepad als Benutzer "" zu starten...
C:\Users\user>runas /noprofile /user:foo_bar\testuser notepad
Geben Sie das Kennwort für "foo_bar\testuser" ein:
Es wird versucht, notepad als Benutzer "foo_bar\testuser" zu starten...
C:\Users\user>runas /noprofile /user:foobar.com\testuser notepad
Geben Sie das Kennwort für "foobar.com\testuser" ein:
Es wird versucht, notepad als Benutzer "foobar.com\testuser" zu starten... I also faced the same issue with the following command. Command – tscon SessionID /dest:console /password:****
Resolution: I worked a lot and finally got to know the issue is with password. i.e. the password length should not be greater than 13 characters. But in this case password = 20 characters.
Later I changed the password to ****(12 characters) and issue got resolved.
1