Gilbert
Gilbert

Reputation: 63

Why Winform WebBrowser doesn't load a page when starting .exe from Windows StartUp

I have a winform application with a webBrowser loading a webpage, all works fine if I execute the .exe by double clicking on it or using the enter key. But, I need to execute this .exe from Windows Startup, so, letting this application to run just after windows starting up. THe problem is that webBrowser doesn't load the web page when the application is started from Windows Startup. This problem is very frustrating for me because the webBrowser actually works executing the application with double click. My Code is:

string curDir = Application.StartupPath;
this.webBrowser1.Url = new Uri("https://www.google.com");

Please, any help. I will appreciate any help. Thanks in advance.

Upvotes: 0

Views: 106

Answers (1)

xtoik
xtoik

Reputation: 676

Probably your computer network connection is not available immediately on startup. You can try a deferred startup (the task scheduler allows to do so), or instead of running directly your executable file run a batch when the command of your application runs after n seconds: to do so you can use:

ping 127.0.0.1 -n 6 > nul

Where the -n command contains the amount of seconds you want to wait.

Upvotes: 2

Related Questions