简体   繁体   中英

Windows 10 - Task Scheduler - Proxy Setting / Authentication

All,

I have a simple C#.Net console application calling a external REST API via a proxy configured in browser. The application works fine from Visual Studio / directly run exe manually. This is a windows 10 desktop

When i try to do the same through a windows scheduled task, the program runs only with the option of user logged in. Else when i choose run whether the user is logged in or not under my context - the program fails stating the that the end point is blocked. Either it never takes the proxy or the proxy authentication fails.

I tried to set the web proxy credentials in code, proxy settings in app.config nothing to the rescue.

Has anyone faced similar issue? Is there a cleaner way to do this?

Thanks, Goutham

I had very similar issue, i could create a scheduled task using my account, but not a service account, well when i did the service account would fail to run the scheduled task, it was due to proxy server in our env.

so i was using this line WebRequest

 WebProxy proxyObject = new WebProxy("Http://proxy:80");
                WebRequest.DefaultWebProxy = proxyObject;

this for some reason let me schedule the task for my.exe i was developing and not work with a service account. apparently WebRequest is old and should not be used i found out.

so i switch to HttpRequest..

WebProxy proxyObject = new WebProxy("Http://proxy:80");
                HttpClient.DefaultProxy = proxyObject;

now i'm able to schedule tasks with no issues with svc account or local account, whatever i want:).

Have you tried authenticating via Login as a service?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM