computer help index
 
 
Search:
"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,490 tips!

Windows XP and DOS

Search Google and Other Search Engines from the Command Prompt

SUMMARY: Create a Windows XP/DOS command line utility that lets a batch file search Google by starting a web browser or displaying the results in a DOS prompt.

Here's an interesting command you can add to your Windows XP and DOS arsenal.

Just take the following text, open Notepad, and create a file google.bat in your main Windows directory (usually c:\windows):

@echo off
if not "%1"=="" (set QUERY=%1) else (goto error)
:loop
shift
if not "%1"=="" (set QUERY=%QUERY%+%1) else (goto exitloop)
goto loop
:exitloop
start http://www.google.com/search?q=%QUERY%
exit
:error
echo You did not enter a search query!


This creates a google command that starts your default web browser and uses the Google search engine to process your search query.

Examples:

google night photography help

google 2006 college basketball statistics

To search MSN's Live.com instead, replace the "start" command with:

start http://search.live.com/results.aspx?q=%QUERY%

To search Yahoo!:

start http://search.yahoo.com/search?p=%QUERY%

To search Ask:

start http://www.ask.com/web?q=%QUERY%

Though interesting, these batch files are not perfect, as certain special characters may trip up the search.

And now, for something completely different...

Why start a web browser session when you can display the results directly in the DOS prompt? Fdisk.com has a Win32/DOS port of the text-based Lynx browser.

Lynx, and this particular port of Lynx, is a third-party utility not written or supported by MalekTips. Standard disclaimers apply.


If you download and extract the archive to c:\lynx you can replace the line of the above batch file prefixed by "start" with the following lines. This displays the top search results directly in the DOS prompt (the results may be messy, but they should be readable):

call c:\lynx\samples\lynx -nolist -dump "http://www.google.com/search?q=%QUERY%" > tmp.htm
more tmp.htm
del tmp.htm


(Note that the first two lines should actually be one line of code in the batch file.)

You may instead want to download the following batch file we have created. This batch file is an enhancement to the one written in this tip. It starts the Lynx web browser if it exists on your hard drive, and if not, your default web browser starts:

* Google search via the Windows XP / DOS command prompt

Be sure to test the batch file before running, and you may need to modify the batch file and/or Lynx's configuration batch file at c:\lynx\samples\lynx.bat. Again, standard disclaimers apply!

 

 
Add: Del.icio.us | Digg | Furl | My Yahoo!
 

Discuss This Tip

Print This Tip

Get E-Mail When New Tips are Online

Return to the Windows XP and DOS page.


More in MalekTips:
Mozilla Firefox - Plugins and ExtensionsGoogle GmailWindows XP and the Keyboard



[MODIFIED] View Pages Rendered in Firefox and Internet ExplorerMove the Chat or Labels Section to the RightPrevent the Cursor from Blinking

RSS Feeds - Subscribe!
 

You want the latest tech tips and tricks in your e-mail Inbox - FREE? Type your e-mail address below and click 'Subscribe'.
 



( sample / details ) ( opt-out instructions )
 


 Free Offer! - Subscribe to the MalekTips computer help list and be one of the first to get new computer tips, articles, and download links! ( privacy policy )  ( opt-out instructions )
This page and its contents are copyright
©1997 - 2008 Envision Programming. ( copyright/disclaimer )

Home | Free Computer Help Newsletter! | Windows | Web Development | DOS and Batch Files | Removing Spyware
Digital Camera and Photography | Computer and Internet | Software | Microsoft Word
Computer Articles | About | Contribute a Tip | Link To Us! | Computer and Technology Links
RSS Feeds |  Contact Us | Advertising | Privacy Policy | Computer Help Forums