Opening a URL containing a query string












2















I need to be able to open a link in a browser from a C# application. Normally, I would use a code like this to open the link:



Process.Start(new ProcessStartInfo("explorer.exe", @"http://www.google.com"));


Unfortunately, that only succeeds in opening explorer and not a browser when the URL contains a query string such as:
http://www.google.com/search?q=stackoverflow



How can I open URLs with query strings?



Edit Notes: I am using Windows 8 with non-IE default browsers. I am seeing the same error with 'Class Not Registered' when trying to use just Process.Start as described here: Process.Start(url) broken on Windows 8/Chrome - are there alternatives?










share|improve this question

























  • What happens when you include a query string?

    – Ash Burlaczenko
    Jan 29 '13 at 14:54











  • I have a class not registered exception -- this situation going on: stackoverflow.com/questions/12206368/… I AM running Windows 8 with Chrome as default browser. My code needs to work with ANY default browser.

    – cvocvo
    Jan 29 '13 at 15:04
















2















I need to be able to open a link in a browser from a C# application. Normally, I would use a code like this to open the link:



Process.Start(new ProcessStartInfo("explorer.exe", @"http://www.google.com"));


Unfortunately, that only succeeds in opening explorer and not a browser when the URL contains a query string such as:
http://www.google.com/search?q=stackoverflow



How can I open URLs with query strings?



Edit Notes: I am using Windows 8 with non-IE default browsers. I am seeing the same error with 'Class Not Registered' when trying to use just Process.Start as described here: Process.Start(url) broken on Windows 8/Chrome - are there alternatives?










share|improve this question

























  • What happens when you include a query string?

    – Ash Burlaczenko
    Jan 29 '13 at 14:54











  • I have a class not registered exception -- this situation going on: stackoverflow.com/questions/12206368/… I AM running Windows 8 with Chrome as default browser. My code needs to work with ANY default browser.

    – cvocvo
    Jan 29 '13 at 15:04














2












2








2








I need to be able to open a link in a browser from a C# application. Normally, I would use a code like this to open the link:



Process.Start(new ProcessStartInfo("explorer.exe", @"http://www.google.com"));


Unfortunately, that only succeeds in opening explorer and not a browser when the URL contains a query string such as:
http://www.google.com/search?q=stackoverflow



How can I open URLs with query strings?



Edit Notes: I am using Windows 8 with non-IE default browsers. I am seeing the same error with 'Class Not Registered' when trying to use just Process.Start as described here: Process.Start(url) broken on Windows 8/Chrome - are there alternatives?










share|improve this question
















I need to be able to open a link in a browser from a C# application. Normally, I would use a code like this to open the link:



Process.Start(new ProcessStartInfo("explorer.exe", @"http://www.google.com"));


Unfortunately, that only succeeds in opening explorer and not a browser when the URL contains a query string such as:
http://www.google.com/search?q=stackoverflow



How can I open URLs with query strings?



Edit Notes: I am using Windows 8 with non-IE default browsers. I am seeing the same error with 'Class Not Registered' when trying to use just Process.Start as described here: Process.Start(url) broken on Windows 8/Chrome - are there alternatives?







c# windows-8 query-string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 2:27









Cœur

18.5k9110148




18.5k9110148










asked Jan 29 '13 at 14:53









cvocvocvocvo

84711333




84711333













  • What happens when you include a query string?

    – Ash Burlaczenko
    Jan 29 '13 at 14:54











  • I have a class not registered exception -- this situation going on: stackoverflow.com/questions/12206368/… I AM running Windows 8 with Chrome as default browser. My code needs to work with ANY default browser.

    – cvocvo
    Jan 29 '13 at 15:04



















  • What happens when you include a query string?

    – Ash Burlaczenko
    Jan 29 '13 at 14:54











  • I have a class not registered exception -- this situation going on: stackoverflow.com/questions/12206368/… I AM running Windows 8 with Chrome as default browser. My code needs to work with ANY default browser.

    – cvocvo
    Jan 29 '13 at 15:04

















What happens when you include a query string?

– Ash Burlaczenko
Jan 29 '13 at 14:54





What happens when you include a query string?

– Ash Burlaczenko
Jan 29 '13 at 14:54













I have a class not registered exception -- this situation going on: stackoverflow.com/questions/12206368/… I AM running Windows 8 with Chrome as default browser. My code needs to work with ANY default browser.

– cvocvo
Jan 29 '13 at 15:04





I have a class not registered exception -- this situation going on: stackoverflow.com/questions/12206368/… I AM running Windows 8 with Chrome as default browser. My code needs to work with ANY default browser.

– cvocvo
Jan 29 '13 at 15:04












4 Answers
4






active

oldest

votes


















7














Finally found a solution -- kind of impressed I didn't try this to begin with after writing batch files years ago this was common.



Process.Start(new ProcessStartInfo("explorer.exe", """ + @"http://www.google.com/search?q=stackoverflow" + """));


Just adding quotes around it seems to work fine.






share|improve this answer































    3














    You can use the default browser with :



    Process.Start(@"http://www.google.com");


    Simple isn't it?



    And it works with query strings:



    Process.Start(@"http://www.google.com/search?q=stackoverflow");





    share|improve this answer
























    • Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

      – cvocvo
      Jan 29 '13 at 15:01











    • That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

      – cvocvo
      Jan 29 '13 at 15:02













    • Yes I am using Windows 8 x64

      – cvocvo
      Jan 29 '13 at 15:05











    • Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

      – cvocvo
      Jan 29 '13 at 15:07











    • @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

      – Cédric Bignon
      Jan 29 '13 at 15:09





















    0














    You just neet do do this:



    try
    {
    Process.Start(@"http://www.google.com/search?q=stackoverflow");
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }





    share|improve this answer































      0














      Try "start" instead of "explorer.exe". Pulling up the command line and typing < start http://google.com?q=blah > worked for me.






      share|improve this answer


























      • I got a "System cannot find the file specified" error

        – cvocvo
        Jan 29 '13 at 15:06











      • @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

        – Louis Ricci
        Jan 29 '13 at 15:25













      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14585709%2fopening-a-url-containing-a-query-string%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      7














      Finally found a solution -- kind of impressed I didn't try this to begin with after writing batch files years ago this was common.



      Process.Start(new ProcessStartInfo("explorer.exe", """ + @"http://www.google.com/search?q=stackoverflow" + """));


      Just adding quotes around it seems to work fine.






      share|improve this answer




























        7














        Finally found a solution -- kind of impressed I didn't try this to begin with after writing batch files years ago this was common.



        Process.Start(new ProcessStartInfo("explorer.exe", """ + @"http://www.google.com/search?q=stackoverflow" + """));


        Just adding quotes around it seems to work fine.






        share|improve this answer


























          7












          7








          7







          Finally found a solution -- kind of impressed I didn't try this to begin with after writing batch files years ago this was common.



          Process.Start(new ProcessStartInfo("explorer.exe", """ + @"http://www.google.com/search?q=stackoverflow" + """));


          Just adding quotes around it seems to work fine.






          share|improve this answer













          Finally found a solution -- kind of impressed I didn't try this to begin with after writing batch files years ago this was common.



          Process.Start(new ProcessStartInfo("explorer.exe", """ + @"http://www.google.com/search?q=stackoverflow" + """));


          Just adding quotes around it seems to work fine.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 29 '13 at 15:16









          cvocvocvocvo

          84711333




          84711333

























              3














              You can use the default browser with :



              Process.Start(@"http://www.google.com");


              Simple isn't it?



              And it works with query strings:



              Process.Start(@"http://www.google.com/search?q=stackoverflow");





              share|improve this answer
























              • Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

                – cvocvo
                Jan 29 '13 at 15:01











              • That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

                – cvocvo
                Jan 29 '13 at 15:02













              • Yes I am using Windows 8 x64

                – cvocvo
                Jan 29 '13 at 15:05











              • Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

                – cvocvo
                Jan 29 '13 at 15:07











              • @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

                – Cédric Bignon
                Jan 29 '13 at 15:09


















              3














              You can use the default browser with :



              Process.Start(@"http://www.google.com");


              Simple isn't it?



              And it works with query strings:



              Process.Start(@"http://www.google.com/search?q=stackoverflow");





              share|improve this answer
























              • Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

                – cvocvo
                Jan 29 '13 at 15:01











              • That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

                – cvocvo
                Jan 29 '13 at 15:02













              • Yes I am using Windows 8 x64

                – cvocvo
                Jan 29 '13 at 15:05











              • Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

                – cvocvo
                Jan 29 '13 at 15:07











              • @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

                – Cédric Bignon
                Jan 29 '13 at 15:09
















              3












              3








              3







              You can use the default browser with :



              Process.Start(@"http://www.google.com");


              Simple isn't it?



              And it works with query strings:



              Process.Start(@"http://www.google.com/search?q=stackoverflow");





              share|improve this answer













              You can use the default browser with :



              Process.Start(@"http://www.google.com");


              Simple isn't it?



              And it works with query strings:



              Process.Start(@"http://www.google.com/search?q=stackoverflow");






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 29 '13 at 14:54









              Cédric BignonCédric Bignon

              10.4k13148




              10.4k13148













              • Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

                – cvocvo
                Jan 29 '13 at 15:01











              • That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

                – cvocvo
                Jan 29 '13 at 15:02













              • Yes I am using Windows 8 x64

                – cvocvo
                Jan 29 '13 at 15:05











              • Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

                – cvocvo
                Jan 29 '13 at 15:07











              • @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

                – Cédric Bignon
                Jan 29 '13 at 15:09





















              • Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

                – cvocvo
                Jan 29 '13 at 15:01











              • That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

                – cvocvo
                Jan 29 '13 at 15:02













              • Yes I am using Windows 8 x64

                – cvocvo
                Jan 29 '13 at 15:05











              • Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

                – cvocvo
                Jan 29 '13 at 15:07











              • @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

                – Cédric Bignon
                Jan 29 '13 at 15:09



















              Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

              – cvocvo
              Jan 29 '13 at 15:01





              Doing this gives me a "Class Not Registered" exception: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start()rn at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)rn at System.Diagnostics.Process.Start(String fileName)rn at QueryStringLaunch.Form1.button1_Click(Object sender, EventArgs e) in D:\Documents\Visual Studio 2010\TestProjects\QueryStringLaunch\QueryStringLaunch\Form1.cs:line 24" string

              – cvocvo
              Jan 29 '13 at 15:01













              That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

              – cvocvo
              Jan 29 '13 at 15:02







              That class not registered error points to this issue: stackoverflow.com/questions/12206368/…

              – cvocvo
              Jan 29 '13 at 15:02















              Yes I am using Windows 8 x64

              – cvocvo
              Jan 29 '13 at 15:05





              Yes I am using Windows 8 x64

              – cvocvo
              Jan 29 '13 at 15:05













              Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

              – cvocvo
              Jan 29 '13 at 15:07





              Ideally that'd be the case but unfortunately over thousands of users I can't expect them to do this.

              – cvocvo
              Jan 29 '13 at 15:07













              @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

              – Cédric Bignon
              Jan 29 '13 at 15:09







              @cvocvo Here you may find the solution to register correctly your browser. Hope it helps.

              – Cédric Bignon
              Jan 29 '13 at 15:09













              0














              You just neet do do this:



              try
              {
              Process.Start(@"http://www.google.com/search?q=stackoverflow");
              }
              catch(Exception ex)
              {
              MessageBox.Show(ex.ToString());
              }





              share|improve this answer




























                0














                You just neet do do this:



                try
                {
                Process.Start(@"http://www.google.com/search?q=stackoverflow");
                }
                catch(Exception ex)
                {
                MessageBox.Show(ex.ToString());
                }





                share|improve this answer


























                  0












                  0








                  0







                  You just neet do do this:



                  try
                  {
                  Process.Start(@"http://www.google.com/search?q=stackoverflow");
                  }
                  catch(Exception ex)
                  {
                  MessageBox.Show(ex.ToString());
                  }





                  share|improve this answer













                  You just neet do do this:



                  try
                  {
                  Process.Start(@"http://www.google.com/search?q=stackoverflow");
                  }
                  catch(Exception ex)
                  {
                  MessageBox.Show(ex.ToString());
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 29 '13 at 14:56









                  codeteqcodeteq

                  1,06058




                  1,06058























                      0














                      Try "start" instead of "explorer.exe". Pulling up the command line and typing < start http://google.com?q=blah > worked for me.






                      share|improve this answer


























                      • I got a "System cannot find the file specified" error

                        – cvocvo
                        Jan 29 '13 at 15:06











                      • @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

                        – Louis Ricci
                        Jan 29 '13 at 15:25


















                      0














                      Try "start" instead of "explorer.exe". Pulling up the command line and typing < start http://google.com?q=blah > worked for me.






                      share|improve this answer


























                      • I got a "System cannot find the file specified" error

                        – cvocvo
                        Jan 29 '13 at 15:06











                      • @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

                        – Louis Ricci
                        Jan 29 '13 at 15:25
















                      0












                      0








                      0







                      Try "start" instead of "explorer.exe". Pulling up the command line and typing < start http://google.com?q=blah > worked for me.






                      share|improve this answer















                      Try "start" instead of "explorer.exe". Pulling up the command line and typing < start http://google.com?q=blah > worked for me.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 29 '13 at 15:24

























                      answered Jan 29 '13 at 14:56









                      Louis RicciLouis Ricci

                      16.7k43557




                      16.7k43557













                      • I got a "System cannot find the file specified" error

                        – cvocvo
                        Jan 29 '13 at 15:06











                      • @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

                        – Louis Ricci
                        Jan 29 '13 at 15:25





















                      • I got a "System cannot find the file specified" error

                        – cvocvo
                        Jan 29 '13 at 15:06











                      • @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

                        – Louis Ricci
                        Jan 29 '13 at 15:25



















                      I got a "System cannot find the file specified" error

                      – cvocvo
                      Jan 29 '13 at 15:06





                      I got a "System cannot find the file specified" error

                      – cvocvo
                      Jan 29 '13 at 15:06













                      @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

                      – Louis Ricci
                      Jan 29 '13 at 15:25







                      @cvocvo - SO remove the <start from the beginning thinking it was an html tag.

                      – Louis Ricci
                      Jan 29 '13 at 15:25




















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14585709%2fopening-a-url-containing-a-query-string%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Angular Downloading a file using contenturl with Basic Authentication

                      Olmecas

                      Can't read property showImagePicker of undefined in react native iOS