Fix Google Chrome

Chrome is so good, it shouldn’t be annoying!

© 2012 by KV5R. Rev. July 24, 2012.

Chrome is great and I love it. But there’s a few things that I, and lots of other people, don’t like. I’ll cover some of them here. Is it legal? Yes, Chrome is built from the open source Chromium, and you can mod it if you want to. You can even get the sources and compile it from scratch if you want to, and you can distribute your modded version. But we won’t be compiling a custom Chrome replacement here, just tweaking things a bit.

Problem 1: New Tab Doesn’t Display Your Homepage

I have a local custom homepage where I put links to all the stuff I use. I set Chrome to use it as my homepage upon start-up. But alas, when opening a New Tab, Chrome displays its built-in New Tab page, with all those stupid “most visited” thumbnails and other stuff I never use. I want it to open my homepage every time I open a new tab, not just upon start-up. People have been complaining about this since 2008 and apparently the Chrome crew simply refuses to make it an option.

This is really pretty easy to fix. Chrome’s new page code is loaded from a resource in chrome.dll. To hack it, do this:

  1. Download and install Resource Hacker (free!).
  2. Locate chrome.dll in the program files folder where Chrome is installed, usually c:\Program Files (x86)\Google\Chrome\Application\latest.version.number\.
  3. Copy it to chrome.orig.dll as a backup.
  4. Run Resource Hacker and open chrome.dll.
  5. Find (Ctrl-F) the text It's important that this be the first script loaded (or very similar; they might change it in later versions).
  6. Put this line right below the “It's important that…” line (make sure it’s above the first <script> tag):
    <script>window.location = 'http://localhost/';</script> (replace localhost with your desired homepage URL). It forces an immediate redirect and ignores the remainder of the new tab resource.
  7. Click Compile then menu File, Save chrome.dll. Start Chrome and test it by opening a new tab.

Notes:

  • You will have to do this again each time Google updates chrome and replaces chrome.dll, so save these instructions in a handy text file.
  • Also in Chrome, set your homepage to New Tab (Wrench, Settings, On Startup, Open the New Tab page). Otherwise, after your mod, it will simply load it twice upon start-up.
  • The only useful thing (IMO) on the New Tab page is Recently Closed Tabs. To restore that handy functionality, install an extension called Recently Closed Tabs.

Problem 2: You Can’t Make Chrome Put its Cache Elsewhere

You just installed a brand-spanking-new solid-state drive, and you’ve read that you should try to move temp and cache files off to a hard drive (see also: my Solid-State Drives pages). All browsers except Chrome allow you to do this from within the browser. But I found a way—in fact, I found three ways!

1. Put DiskCacheDir or UserDataDir in the Registry

This easy method will move the cache location to a folder of your choice. The rest of the user profile stuff will stay where it is by default.

  • Run regedit and open up the tree to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome. If not there, create it:
    1. Right-click Policies and click New and Key. Name it Google.
    2. Right-click Google and click New and Key. Name it Chrome.
    3. Click Chrome. Right-click in the right side of the screen and click New, String Value, and name it DiskCacheDir.
    4. Double-click DiskCacheDir and put in location desired. I used H:\temp\Chrome. You may be tempted to use an Expandable String Value and put like H:\temp\Chrome\%HOMEPATH% in there—I tried it (many ways) and it just won’t work. Apparently, Chrome expects a REG_SZ data type, not a REG_EXPAND_SZ.
  • But fascist Google Update will delete it at the next update! To stop this Nazi Google behavior:
    1. Right-click that Google key you made under Policy and choose Permissions. Notice that SYSTEM and Administrators have Full Control, and they are all grayed out, because they are Inherited.
    2. Click Advanced. Uncheck “Include Inheritable Permissions…” and click Remove on the warning box that pops up. Now all permissions are removed, so you’ll have to explicitly re-create them.
    3. Click Add, Advanced, Find Now, and scroll down and click SYSTEM. Ok, Ok.
    4. Then, in the Permissions box that pops up, check to allow only “Query Value” and “Read Control”. Ok. Apply.
    5. Now repeat above but add Administrators, and Check “Full Control” and then uncheck “Delete”. Ok, Apply, Ok, Ok. Now even you can’t delete the \Google\Chrome keys, unless you give Administrators permission in the Google key! Note that only the user listed in the Owner tab can change permissions on folders, files, and registry keys.
  • Now do all the above again, this time in HKEY_CURRENT_USER\Software\Policies\Google\Chrome.
  • If you have multiple users, you’ll need to put the keys and value you added in HKEY_CURRENT_USER also in the HKEY_USERS trees for each S-1-5-SomeLongNumber (called SIDs) user trees, and set them to a different cache folder in your temp location. You can tell which SID is which user by typing wmic useraccount get name,sid at a command prompt. The real human users’ SIDs will likely end in 1001, 1002, etc., and the other SIDs are for SYSTEM and such.
  • Now, without Chrome running, go to c:\Users\YourUserName\AppData\Local\Google\Chrome\User Data\Default\Cache\ and delete it.
  • Reboot, then start Chrome and go to some web page. Look in the folder you set above and make sure it’s putting its cache files there, and not in the old location.
  • The policy settings you put in the registry cannot be overridden with Chrome’s command-line switches.
  • Ref.: http://www.chromium.org/administrators/policy-list-3#DiskCacheDir
  • There’s a bunch of other values you can control in the same manner; look it up.

If you want to move the whole Chrome user data tree (everything in c:\Users\your-name\AppData\Local\Google\Chrome\User Data\, including the cache) to another drive, do like above but name the string value UserDataDir, and set it to something besides temp, like H:\ChromeUsers. You don’t need both UserDataDir and DiskCacheDir in the registry, as UserDataDir will also relocate the cache. If you do use UserDataDir, note:

  • This will stop all Chrome writing on your SSD except for updates.
  • After adding UserDataDir to the above reg keys (and rebooting), run Chrome and it’ll make the its default user data stuff in the path you specified, but the browser will come up like a new install. To get all your settings (bookmarks, history, etc.) into it, move all the stuff in c:\Users\your-name\AppData\Local\Google\Chrome\User Data\ to the new location, overwriting what Chrome put therein. Then fire up Chrome and verify all your settings, bookmarks, extensions, etc., are working.
  • This has the disadvantages of (a) if you pull your data drive, poof! Chrome won’t work, and possibly (b) it’ll likely not work for multiple users with different profiles, since you specified in the registry that all instances of Chrome, by Windows Policy, will have Chrome User Data hard-wired to a specific drive and folder.
  • As above, if you have multiple users, you’ll need to put the keys and value you added in HKEY_CURRENT_USER also in the HKEY_USERS trees for the other users’ SIDs.

As for now, I have set (and recommend) just putting the DiskCacheDir in the registry, and keeping the rest of the user profile stuff with Chrome, on the SSD.

2. Use Command Line Switches

You can use Chrome command line switches for anything listed that’s not in Policies\Google\Chrome in the registry (which override command line switches).

  • Right-click the icon you use to start Chrome and select Properties.
  • Add the --user-data-dir flag to chrome.exe, like this: chrome.exe --user-data-dir=H:\Chrome-User OR, to just relocate the cache only:
  • chrome.exe --disk-cache-dir=H:\Chrome-User .
  • This method has the disadvantage of only working when you start it with that icon. Instances started by a “default browser” operation (like, clicking a link in an email) will not get the switch, unless several instances are edited in the registry to include the switch. So you’re better off just using #1 above, and making the change global.
  • Re: http://www.chromium.org/user-experience/user-data-directory

3. Relocate ALL of Chrome to Another Drive

This method is somewhat complex, but has the advantage of being portable and completely self-contained, id est, you can pull your external drive and take it with you, settings and all, and use it on another computer without leaving any traces on the host system.

  1. Note: in each case below, replace H: with your actual hard drive letter.
  2. Download and install GoogleChromePortable to the hard drive, from PortableApps.com. Don’t run it yet.
  3. Look in the H:\PortableApps\GoogleChromePortable\ folder for help.html and read it. Migrate your existing profile, as it says.
  4. Copy H:\PortableApps\GoogleChromePortable\Other\Source\GoogleChromePortable.ini to H:\PortableApps\GoogleChromePortable\.
  5. Open it in an editor and look for lines RunLocally=true and CacheInTemp=true and change them both to false. Save and exit.
  6. Now run GoogleChromePortable.exe (double-click it) and look in your C:\Users\your-username\AppData\Local\Temp\ and verify that no GoogleChromePortable folder exists therein. Also, make sure your profile and settings stuff in GoogleChromePortable are all as expected (homepage, bookmarks, extensions, etc).
  7. Now you can completely uninstall Chrome from the SSD, using Control Panel. Your default browser will revert to Internet Explorer, but we’ll fix that later.
  8. To make a handy icon, go to \PortableApps\GoogleChromePortable\, right-click GoogleChromePortable.exe, Send to… Desktop (create shortcut), then you can use it there or drag it into the menu system or pin it to the taskbar, as desired.
  9. To set it as your default browser is a little more complicated. If you make GoogleChromePortable your default browser, Chrome will use the wrong path in several places in the registry, and it simply won’t work. In that case, you need to edit the registry. Be careful, and make a restore point first, if you are new to registry editing.
    1. Run GoogleChromePortable and if it asks to make it your default browser, do so, else click the wrench, Settings, and make it default there.
    2. It will write registry entries, but they will be wrong. The entries need to point to GoogleChromePortable.exe, not \App\Chrome-bin\chrome.exe.
    3. Run regedit and Find (in Data) H:\PortableApps\GoogleChromePortable\App\Chrome-bin\chrome.exe and change it to H:\PortableApps\GoogleChromePortable\GoogleChromePortable.exe in about 11 places.
      • Most of those keys will have -- "%1" after the exe, don’t remove it.
      • The ones to change will look like: "H:\PortableApps\GoogleChromePortable\App\Chrome-bin\chrome.exe" -- "%1"
      • Change them to look like: "H:\PortableApps\GoogleChromePortable\GoogleChromePortable.exe" -- "%1"
      • You can change the first one found, select and copy the changed text, then just paste it into the remaining ones.
      • Keep hitting F3 to find the next, ’til all are found and changed.
      • Do NOT replace the ones that say \PortableApps\GoogleChromePortable\App\Chrome-bin\chrome.exe,0 — this is a path to an icon, which is in chrome.exe, not the launcher GoogleChromePortable.exe, and you don’t need to change the icon location that Windows uses for Chrome.
      • Lastly, open an email or something with a link in it, click it, and see if it runs GoogleChromePortable.exe, not chrome.exe.

Note that the automatic Google Updater does not work with GoogleChromePortable, so check with PortableApps.com every few months to see if there is a later version there.

Fix Google Update

Google Updater is another example of Google’s heavy-handedness. It wants to check for updates ever hour! Fixing this is easy:

  1. Go to Start, All Programs, Accessories, System Tools and run Task Scheduler.
  2. In the left pane, click Task Scheduler Library.
  3. In the right pane you’ll see two GoogleUpdateTask entries.
  4. Double-click one and click the Triggers tab.
  5. Double-click the trigger’s Description to open the Edit Trigger dialog box.
  6. Set it to Weekly and pick a day.
  7. If Repeat Task Every is checked, uncheck it.
  8. To completely disable all Google Updates, uncheck Enabled at the bottom of the Edit Trigger dialog box.
  9. Now Ok all that and then do the other one.
  10. Now Google will check for updates once per week, not once per hour!
  11. When it does do an update, you’ll have to fix this again.
  12. If you turn updating completely off, you can make it check for updates manually by clicking the Wrench, then About Google Chrome.

Other Things

For a list of command line switches, see Chrome Switches.

Interesting switches to try:

  • --disk-cache-dir Use a specific disk cache location, rather than one derived from the UserDatadir.
  • --disk-cache-size Forces the maximum disk space to be used by the disk cache, in bytes.
  • --media-cache-size Forces the maximum disk space to be used by the media cache, in bytes.
  • --disable-application-cache Disable the Application Cache.
  • --parent-profile Specifies the path to the user data folder for the parent profile (whatever that is).

Please say “Thanks!” by sending all your friends here and linking to my pages!

—KV5R

Leave a Reply

Your email address will not be published.