5

Does anyone know how to launch chrome and immediately open a "chrome url"?

I'm trying to make a shortcut like this, but its not working when I tried. it only accepts http:// urls

GoogleChromePortable.exe "chrome://settings/"

Thanks in advance who can help out

3
  • Interesting... GoogleChromePortable @ portableapps?
    – Alvin Wong
    Feb 28, 2013 at 9:18
  • yes, its from portableapps. I also tried on an installed chrome browser and its not working
    – fedmich
    Feb 28, 2013 at 11:54
  • Can't find a way. I already tried quite a few attempts to "hijack" Chrome but seems that Chrome is secure enough to stop me :P
    – Alvin Wong
    Feb 28, 2013 at 13:03

5 Answers 5

5

OK, so I finally figured out a "hack". This hack requires creating an extension to handle the request. I already tried quite a few attempts to "hijack" Chrome with an easier way but seems that Chrome is secure enough to stop me from doing that and this is the closest I can get.

First, create an empty directory somewhere accessible on the hard drive.

Create a file manifest.json with the following content:

{
    "name": "Open Chrome URLs",
    "version": "1.0",
    "manifest_version": 2
}

Create a file open.html with the following content:

<html>
<head>
<title>Open Chrome URLs</title>
<script type="text/javascript" src="open.js"></script>
</head>
<body>
</body>
</html>

Create a file open.js with the following content:

window.addEventListener("load", function(){
    var key = "secretKey"; // replace "secretKey" with your own secret key
    if(window.location.search == "?key=" + key && window.location.hash.length > 1){
        chrome.tabs.update({
            'url': "chrome://" + window.location.hash.substr(1) + "/"
        });
    }else{
        document.body.appendChild(document.createTextNode("Invalid"));
    }
});

Replace the secret key with your own if wanted.

Then, open the Extensions page (chrome://extensions/).

Check the "Developer mode" checkbox and click "Load unpacked extension" and select the directory that you just created.

You should now see a new extension appeared.

New extension

Copy the extension id.

Finally, start Chrome with the following URL as the parameter.

chrome-extension://nihlceAnywayPutTheExtensionIdHere/open.html?key=secretKey#settings

Replace the first part with the extension id with the one you just copied.

Also replace the secretKey with the one you set above.

You can also use most of the other Chrome URLs instead of settings.

Note: you need a shortcut to Chrome instead of an Internet link.

Good luck!

3
  • 1
    Hey Alvin, Thanks for your effort on this. Since I'm also a extension developer. I understand what your codes here are. Nice hack if I may say, but its a bit overkill though. I'm still looking for a simpler commandline solution, but +1 for you already :)
    – fedmich
    Feb 28, 2013 at 23:38
  • @fedmich Because Chrome did its best on security, you can't simply open chrome://settings/. Even in an extension using window.location.replace("chrome://settings/") fails (try in console :[ ). I can only use chrome.tabs.update to accomplish this. Would like to know if any simpler solution.
    – Alvin Wong
    Mar 1, 2013 at 4:10
  • Yup, if the "hacked" extension is disabled then this functionality is broken. Let's wait a while, someone else might be able to give another approach.
    – fedmich
    Mar 1, 2013 at 4:18
3

Here’s a very simple AutoHotkey solution:

WinActivate Chrome 
send ^t
sleep 100 
sendraw chrome://settings/ ; any URL works 
sleep 100 
send {enter}
1

The following AutoHotkey script can be used for a variety of Chrome-based browsers.

; This script opens the "About" page in a Chrome-based Web browser
; -------------------------------------
; To use a different Chrome variant, change the following variables
EnvGet, pf, ProgramFiles(x86) ; For 64-bit browsers: ProgramW6432
dir = %pf%\Google\Chrome\Application ; Browser's drive and directory
protocol = chrome ; Start of the URL, and also the name of the Windows process
tabName = New Tab - Google Chrome ; How the browser names new tabs
; -------------------------------------
proc = %protocol%.exe ; Full name of the Windows executable file
app = %dir%\%proc% ; Full path to the browser
winTitle = ahk_exe %proc% ; Identify the window by the executable file's name
Menu, Tray, Icon, %app% ; Use the browser's icon for this script
Process, exist, %proc% ; See whether the browser is already running
If NOT ErrorLevel ; Browser is not currently running, so run it
 Run, "%app%"
WinWait, %winTitle%,, 200
If ErrorLevel
{
 MsgBox, 48, Error, Browser window was not found.`n`nRef: %A_ScriptFullPath%
 Exit, 1
}
WinActivate, %winTitle%
Send ^t ; Open a new tab in the browser
WinWait, %tabName%,, 20
If ErrorLevel ; The new browser tab was not found
 Exit, 1
Sleep, 100
WinActivate, %winTitle%
Send %protocol%://settings/help{ENTER} ; Open the browser's "About" page
Exit
1

Checked on version 2: AuthoHotKey, it works for me!

Run "C:\Program Files\Google\Chrome\Application\chrome.exe"
sleep 2000 
send ^t
sleep 100 
send chrome://settings/help
sleep 100 
send {Enter}
Exit
1
  • Same answer is given above
    – Toto
    Apr 1, 2023 at 8:08
0

Once chrome starts, go into the chrome://settings/ Url and then the option for on startup select use a specific URL. Put the chrome settings url there and click ok. You then select the bubble for that option and it will will start to that settings page. Now if you want this to be more of an alias solution simply copy the chrome binary and configs or if you are on mac os x copy the app package and do this with the second version or primary your choice. You should also rename the binary and configs but again there is always more than one way to do it. And then define your shortcut or alias accordingly.

1
  • Thanks for helping. but I need a solution in Windows. I need it in a shortcut lnk file. then perhaps later on I could code it up
    – fedmich
    Feb 28, 2013 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .