Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.