Sometimes you may run into a situation where:
- You have a proxy server that requires authentication
- You are unable to run the program under an account that has proxy access
- The program doesn’t respond to “407” Proxy Authentication Required by prompting for the credentials , instead it just fails.
This might occur if you have a web-based installer but want to install it on a “clean install, non domain joined machine” but the only network available requires all internet access be authenticated via a proxy server.
For example if you run Windows ADK setup under an account without credentials to a configured proxy server, the setup will fail Access Denied. Using a tool like Fiddler http://fiddler2.com you will see a plethora of 407 “Proxy Authentication Required” responses.
You can use RunAs cmd with the /netonly command to keep your current user context, but use the specified credentials for network access only. Importantly RunAs with /netonly can be used to connect with domain credentials even on a machine that is only part of a workgroup. This can also be used if you are forced to use a local account, but want network authentication with domain credentials.
runas /netonly /user:<domain\username> <process to launch>
However it is important to know this command does not attempt to verify your credentials are correct. If you type them incorrectly (i.e. wrong password) the RunAs will not fail, only any attempted network access will fail. (and you might lock out your account!)
For example, even a totally made up domain/username/password combination will “work” However when the credentials are attempted to be used to access a network resource, they will fail.
This method can also be used for connection to network shares.
Alternatively, you could configure Fiddler to perform the authentication on your behalf by using the X-AutoAuth Session flag, containing the username/password.
Thanks, that is also good to know.