Getting a batch file to search Google

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
skynet
Posts: 3
Joined: 07 Nov 2011 12:17

Getting a batch file to search Google

#1 Post by skynet » 07 Nov 2011 12:29

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.

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Getting a batch file to search Google

#2 Post by Ranguna173 » 07 Nov 2011 13:02

What browser do you want to use?

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Getting a batch file to search Google

#3 Post by Ranguna173 » 07 Nov 2011 13:20

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..

skynet
Posts: 3
Joined: 07 Nov 2011 12:17

Re: Getting a batch file to search Google

#4 Post by skynet » 07 Nov 2011 13:55

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

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Getting a batch file to search Google

#5 Post by Ranguna173 » 07 Nov 2011 14:39

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?

aGerman
Expert
Posts: 4705
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Getting a batch file to search Google

#6 Post by aGerman » 07 Nov 2011 15:36

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

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Getting a batch file to search Google

#7 Post by Ranguna173 » 07 Nov 2011 15:47

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..

skynet
Posts: 3
Joined: 07 Nov 2011 12:17

Re: Getting a batch file to search Google

#8 Post by skynet » 09 Nov 2011 12:25

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

Post Reply