File not found when shell website url (VB.Net)

Hello guys.

I am trying to run .exe file and website url using the

Open in new window

method but it seems like it does not work well for me.
I used XML file to store my .exe path and website url and I can only run .exe file. When comes to the website url it said that
File not found
but when I checked it, the path is actually correct.

Can anybody suggest the best and simple solution as I am not really expert in VB? Thanks.
alvera aAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
Shell is an old VB6 command that was left in VB.NET only to ease the transition. It is limited in what it can to. It will start a .exe, but nothing else. Because your url is not a .exe, Shell cannot start it.

Use the .NET Process class instead. It can start either a .exe, a file or a valid address (http, ftp, mail)

alvera aAuthor Commented:
Thank you so much for replying and your solution. I actually tried the Process.Start() also and it works fine when run the website url but not for .exe file. It returns me this error.
The system cannot find the file specified
Here is my coding.
Dim i As Integer, j As Integer

        For i = 0 To 9
            For j = 0 To 9
                If MenuListBox.SelectedItem = MenuListBox(i, j, 0) Then

                    Shell(MenuListBox(i, j, 1))

                End If

Open in new window

I used XML file to store my .exe file and website url then use array to hold them. My program is a menu which is when I click it, the program will run the .exe file or opening the website url refer to their own path.
Is there any solution for this? Thanks.
Jacques Bourgeois (James Burger)PresidentCommented:
For a .exe, you need to give the whole path. Check the values in your array to make sure that you have the correct paths for each .exe.

You can help yourself with that by adding a Debug.WriteLine(MenuListBox(i, j, 1)) line just before the Shell. This will send the urls and filenames to the Output Window. When you get the error, the last one listed will be the one that causes the problem.
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

alvera aAuthor Commented:
Oh a huge sorry from me. The code that I posted just now is actually working fine when running the .exe file but not working for website url.

My program will throw error "The system cannot find the file specified" IF I use Process.Start() when running the .exe file but working fine when running the website url.

Sorry for confusing.
Jacques Bourgeois (James Burger)PresidentCommented:
It was late for me, so I did not catch that you are still using Shell. I told you in my first answer that Shell works only for .exe.

Use Process.Start instead.
alvera aAuthor Commented:
Yes I already change to Process.Start()

Here is my latest coding that working all fine now.

Dim Path As String = MenuListBox(i, j, 1)

    If Path.Contains(".exe") Then
    End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jacques Bourgeois (James Burger)PresidentCommented:
The final solution shown by the asker follows what I suggested. He probably did not close the question correctly by not giving the points.
Jacques Bourgeois (James Burger)PresidentCommented:
@alvera a

Process.Start is good for both. You can completely ignore Shell.
alvera aAuthor Commented:
I tried to use Process.Start() method to run both .exe and website but it seems like it only working for running website (in my program case). It throws me an error like 32WindowsException was unhandled if I run my .exe using Process.Start(). So the only solution that I found is using both Shell() and Process.Start() inside my program. As long as it is working fine for my program I think it is ok already. I will try hard to improve my coding by using Process.Start() instead of Shell() next. Thank you :)
alvera aAuthor Commented:
Shell() is used to run all path that containing .exe file and Process.Start() is used to run website url.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.