Category Archives: CMD

Google search from windows command line

Create a batch file called “google.bat”.

Put it in a directory, say C:\bat\google_cmd


@ECHO off

SET s=""
IF NOT "%1"=="" SET s=%1
IF NOT "%2"=="" SET s=%s% %2
IF NOT "%3"=="" SET s=%s% %3
IF NOT "%4"=="" SET s=%s% %4
IF NOT "%5"=="" SET s=%s% %5
IF NOT "%6"=="" SET s=%s% %6
IF NOT "%7"=="" SET s=%s% %7
IF NOT "%8"=="" SET s=%s% %8
IF NOT "%9"=="" SET s=%s% %9

pushd "C:\Program Files\Mozilla Firefox"
IF "%s%"=="""" (
START firefox.exe www.google.com
) ELSE (
START firefox.exe -search "%s%"
)
popd

Add C:\bat\google_cmd to PATH. Do this by WindowsKey-Break -> Advanced System Settings -> Environment Variables -> System variables -> PATH -> Edit… append it on the end

Now you can google search via run (WindowsKey-R) google [search term] e.g. google ferrari f40