Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Windows 7 I'm using runas /netonly /user:... to run something under a different account. If I mistype the password the program starts under my current user.

runas doesn't even appear to set the ERRORLEVEL when this happens. Is there any way to detect when the user mistyped and failed to log on to the new account? The following doesn't work:

runas /netonly /user:my_other_username c:\programs\etc\something.exe
if ERRORLEVEL 1 pause

Why does the program start, rather than failing and reporting the bad password? I can't think of any good reason why this should be the default behaviour.

share|improve this question
up vote 0 down vote accepted

With /netonly, the provided credentials are only applied to network connections (SMB, RPC). The process is being run as the same local user. Therefore, runas has no way of knowing whether you entered the correct password.

To actually run a program as different account, omit the /netonly switch.

share|improve this answer
I see, so it's actually running as the local user. I suppose that makes sense. Rubbish. Shame there's no way it could test a network connection with the supplied credentials. – Joe Kearney Jan 24 '11 at 18:55
@Joe: Since it cannot know what network connections you are going to use, no. – grawity Jan 25 '11 at 5:47
That's a fair point. – Joe Kearney Jan 25 '11 at 9:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .