SetCredentials takes a target flag. Passing the server flag while diagnosing a proxy challenge configures a different authentication relationship.

For the WinHttpRequest automation object, the proxy target is HTTPREQUEST_SETCREDENTIALS_FOR_PROXY, whose value is 1. A compact fragment is:

Const ProxyCredentials = 1
request.Open "GET", "https://example.com/", False
request.SetCredentials proxyUser, proxyPassword, ProxyCredentials
request.Send

This assumes the intended proxy has already been selected and the account values come from the application's normal configuration. Credentials are set after a successful Open. If the destination also needs credentials, that is a separate target and a separate assignment.

Read the final status and authentication method rather than treating successful assignment as successful login. The proxy can reject an unsupported scheme or an account that lacks permission.

An old recipe may also disable SSL error checks. That does not repair a credential assigned to the wrong target. Keep normal certificate validation and diagnose any later TLS error on its own connection.

Winndannde jowitiiɗe heen