In earlier versions of Windows (before 8 and 10). You could simply execute this piece of code:
class Program
{
static void Main(string[] args)
{
TryStart("myapp:", "https://www.google.com");
}
private static void TryStart(String url, String raw = "")
{
try
{
if (!String.IsNullOrEmpty(url))
{
Process.Start(url);
}
}
catch
{
if (!String.IsNullOrEmpty(raw))
{
Process.Start(raw);
}
}
}
}
And it would work perfectly. If the program didn't exist, it would open the webpage. If the program did exist, it would open it.
However, in Windows 8 and 10, if the program doesn't exist, you will get this message instead:
And the website would never be opened. Is there another way around this?