2

Is it possible from the Windows command line to both:

  • Start the default web browser
  • and have it query the default search engine within that browser

The command would work correctly in this type of scenario:

  • Firefox the default browser and Wikipedia the default search engine
  • IE the default browser and Google the default search engine
  • etc...

A reasonable alternative if such a command does not exist would be to retrieve this information from the registry (or wherever it is stored).

Is this possible and how?

2
  • I'm not an expert but this sounds like it shouldn't been too hard to accomplish with PowerShell... but with the command line, I'm not sure.
    – Travis
    Aug 26, 2009 at 14:43
  • T Pops: Even with Powershell my answer applies and it's still not pretty. It involves fairly much guessing, knowledge about different browsers, &c.
    – Joey
    Aug 26, 2009 at 21:46

2 Answers 2

4

I'm afraid this is not possible. Starting a specified URL with the default browser is easy enough using

start http://some/url

Querying the default search engine, however, is not that easy since different browsers tend to store it in vastly different locations if anywhere accessible at all. Internet Explorer for example stores its search engines in

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchScopes

but Firefox and others probably store it in different locations (I mean, a single unified location for settings common to all browsers would be convenient for users but developers would hate it, especially if that would be a single unified location dictated by Microsoft).

You might try different code paths to determine the default search engine depending on the default browser. But the default browser is also only loosely specified and could be obtained by looking which program is associated with the HTTP protocol handler.

But that borders dangerously close to guessing, with ginormous amounts of work on the other side of the cliff. So in general I'd say it's nearly impossible unless you pur more work into it that you likely want.

ETA: Some browsers, such as Firefox allow for searching directly from the command line, using the default search engine:

firefox.exe -search keyword

or

opera.exe ? keyword

But this still leaves you with the problem of figuring out the default browser and determining the appropriate arguments from that.

1
  • If you use your firefox/opera method it should work with their default search engine
    – Ivo Flipse
    Aug 26, 2009 at 17:55
0

I'm pretty sure Launchy can do that

It's not exactly a command line, but it's close enough.

It is a line where you type commands, but it's just not a shell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .