Page 1 of 1

Getting a batch file to search Google

Posted: 07 Nov 2011 12:29
by skynet
Hi all

I am a photocopier engineer and when I have a strange ongoing problem with a machine I search a website using google site search like this for example.,

blank copies site:http://www.copytechnet.com/forums/canon/

Is there a way to get a batch file to do the search for me so I can start the file, enter my search details and the file adds 'site:http://www.copytechnet.com/forums/canon/' to the end.

Many thanks.

Re: Getting a batch file to search Google

Posted: 07 Nov 2011 13:02
by Ranguna173
What browser do you want to use?

Re: Getting a batch file to search Google

Posted: 07 Nov 2011 13:20
by Ranguna173
if it is firefox, here is the code:

Code: Select all

@echo off
echo Type what you want to search in google.
echo Put  + where you put the spaces. Ex:
echo -
echo You want to search.
echo Would be:
echo you+want+to+search
set /p search=
cd "C:\Program Files\Mozilla Firefox"
firefox http://www.google.pt/search?q=%search%


I'm not in the mood to write something that would replace spaces with pluses so you just need to put a + in the place of spaces..

Re: Getting a batch file to search Google

Posted: 07 Nov 2011 13:55
by skynet
I use Firefox but can adapt the file for IE which I use at work.

My main reason for this is so I don't have to type the following into Google

site:http://www.copytechnet.com/forums/canon/

I want the script to do that for me I want it to open Google like this

I have tried
[snip]
cd "C:\Program Files\Mozilla Firefox"
firefox http://www.google.pt/search?q=%search% site:http://www.copytechnet.com/forums/canon/

but that doesn't work

Re: Getting a batch file to search Google

Posted: 07 Nov 2011 14:39
by Ranguna173
No, what you need to do is :

Code: Select all

firefox http://www.google.pt/search?q=%search%[b]+[/b]site:http://www.copytechnet.com/forums/canon/


You can't use spaces.
Use + google will read them as spaces..

For the internet explorer:

Code: Select all

cd C:\Program Files\Internet Explorer
iexplore http://www.google.pt/search?q=%search%+site:http://www.copytechnet.com/forums/canon/


Do you want me to create a batch file that you can choose between internet explorer and firefox?

Re: Getting a batch file to search Google

Posted: 07 Nov 2011 15:36
by aGerman
You could also replace the spaces automatically and you could use the default browser:

Code: Select all

@echo off
set "google=http://www.google.com/search?q="
set "site=+site:http%%3A%%2F%%2Fwww.copytechnet.com%%2Fforums%%2Fcanon%%2F"

set /p "string=Search Details: "
set "string=%string: =+%"

start "" %google%%string%%site%

Regards
aGerman

Re: Getting a batch file to search Google

Posted: 07 Nov 2011 15:47
by Ranguna173
aGerman wrote:You could also replace the spaces automatically and you could use the default browser:

Code: Select all

@echo off
set "google=http://www.google.com/search?q="
set "site=+site:http%%3A%%2F%%2Fwww.copytechnet.com%%2Fforums%%2Fcanon%%2F"

set /p "string=Search Details: "
set "string=%string: =+%"

start "" %google%%string%%site%

Regards
aGerman


Or that..

Re: Getting a batch file to search Google

Posted: 09 Nov 2011 12:25
by skynet
Thanks for the help it now works as I wanted, I will adapt it to work with IE now I have the most difficult part (for me) sorted.

Thanks again. :D