Solved batch file to extract address from .url file

May 11, 2012 at 00:16:39
Specs: Windows 7
Google Chrome doesn't handle .url files unless it's set as the default browser. I don't want to set it as the default browser but I still want the option to open .url files with Chrome using a batch+registry command.
I made this batch file to search each line a .url until it finds the URL= string and then launch chrome with the address on that line. It works for some .url files and doesn't for others. The problem is all .url files are not alike. Some have 2 lines some have 4 lines some have 12 lines. The batch files doesn't seem to be going through all of the lines. The script doesn't work right or it isn't nested properly.

@Echo Off
SETLOCAL
(FOR /L %%i IN (1,1,9) DO SET /P url=) < %1
If /I %url:~0,4%=URL START %LOCALAPPDATA%\Google\Chrome\Application\chrome.exe --new-tab-page-1 "%url:~4%"
ENDLOCAL

Line 1-9 is usually where the URL= address is so I used that as the range.
Some help would be appreciated.


See More: batch file to extract address from .url file

Report •


#1
May 11, 2012 at 01:09:50
Post your file.


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
May 11, 2012 at 03:29:13
script is in the first post.

----------ChromeURLParser.bat
@Echo Off
SETLOCAL
(FOR /L %%i IN (1,1,9) DO SET /P url=) < %1
If /I %url:~0,4%=URL START %LOCALAPPDATA%\Google\Chrome\Application\chrome.exe --new-tab-page-1 "%url:~4%"
ENDLOCAL
------------------------------------------


Report •

#3
May 11, 2012 at 16:33:09
✔ Best Answer
Mechanix2Go: Post your file.
He lives!

Untested and I've been drinking:

@for /f "delims=" %%a in ('findstr /b "URL=" "%~1"') do @set %%a
@START "" "%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe" --new-tab-page-1 "%URL%"

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
May 11, 2012 at 19:13:06
It works! Tested on different .url files and all opened. Can't thank you enough.

You should post this on the Google Chrome community forum since you re-wrote it and there are some users looking for this solution. Or, do you mind if I post it along with my registry file that's add 'Open in Google Chrome' to url files?


Report •

#5
May 11, 2012 at 19:31:53
It's a two line batch file I wrote while drinking, and created because I wanted to contribute something other than shock at M2G's resurrection. Do with it what you will.

How To Ask Questions The Smart Way


Report •


Ask Question