Redirecting filepaths or binding paraameters to an EXE

Page 1 of 2 12 LastLast

  1. Posts : 29
    Win7 Home Premium 64x
       #1

    Redirecting filepaths or binding paraameters to an EXE


    Hello,

    I was wondering if anyone knew of any methods or tools to do this. I am looking to make it so that chrome constantly runs with its --user-data-dir and --cache flags. They are different from the defaults, obviously and I was looking for a less clumsy manner than to use a a directory junction.

    Is there a way to make it so that chrome.exe always starts with these parameters? I can use shortcuts for a lot, but programs like skype refuse to oblige me.

    I've tried editing the registry for the types of files chrome opens, but it's tedious and just not worth the trouble. Is there a cleaner solution?

    Worst case scenario, I might write a windowless VB program and name it chrome.exe (in the same dir) that opens the real thing with the proper parameters, but I'm wondering if there's something a bit less unorthodox and more direct?

    Perhaps a way to bind application parameters to the .exe?

    I have also, out of curiosity, tried MKLINK for a symbolic directory changing filetypes (chrome.exe redirects to a LNK with the parameters) but for reasons I probably should have anticipated, this is obviously not working. Perhaps I'm on the right track, however....

    Many thanks for any suggestions or assistance.

    Or should I just leave it on my SSD and get over the writes?
      My Computer


  2. Posts : 1,711
    Win 7 Pro 64-bit 7601
       #2

    Afaik, giving parameters in a shortcut properties window works for chrome. As long as it is being launched from the shortcut anyway.

    Anyway, MKLINK works fine if you use it to simply redirect stuff from a folder to another and not to pull shenanigans on an exe.

    Copy-pasting someone elses's work from here:
    Code:
    mklink /D "C:\Users\Bapa\AppData\Local\Google\Chrome\User Data\Default\Cache" "D:\chrome_cache"
    
    Let's break it down.
    The first term, "mklink" is the name of the command line program we'll be using.
    /D is a command-line switch to tell it to link to a directory.
    The first parameter, in quotation marks, is the location we want our symbolic link to be placed.
    The last parameter is the location we want to link to.
    
    Note: The file system that you want to place the symbolic link on must be NTFS.
    This
    Code:
    mklink /d "C:\Users\<account>\AppData\Local\Google\Chrome\UserData\Default" "C:\YourPath\Default"
    should do the trick for the user data folder.

    Or should I just leave it on my SSD and get over the writes?
    Won't impact its lifespan that much. Most SSDs are supposed to last decades with 2-4 GB written per day, every day.
      My Computer


  3. Posts : 29
    Win7 Home Premium 64x
    Thread Starter
       #3

    While I appreciate the response - I did specifically mention that I was looking to avoid using directory junctions/symbolic links if at all possible. I also mentioned that shortcuts will not work since they are only a localized solution and I need a global one.

    I'm probably stuck just using my chrome.exe VB workaround. I'm thinking on an SSD it shouldn't impact the start of the program that heavily; I was just looking to avoid installing VB...
      My Computer


  4. Posts : 5,092
    Windows 7 32 bit
       #4

    What you are talking about is common practice on systems that directly support aliases in the shell. One common example is the ls command in Linux. Typically it has params tacked on for formatting the output so that you just have to type
    ls filepattern
    in the shell command prompt.

    You can do similar stuff with .cmd files.
    for example,
    chrome.cmd file with
    c:\program files\chrome\chrome.exe --param1 --param2 %*
    (the %* means to substitute the entire command tail. Any urls will be passed to chrome)
    Last edited by MilesAhead; 28 Jun 2013 at 10:42. Reason: Just change the shortcut to point to the cmd such as C:\MyCMDfolder\chrome.cmd
      My Computer


  5. Posts : 29
    Win7 Home Premium 64x
    Thread Starter
       #5

    MilesAhead said:
    What you are talking about is common practice on systems that directly support aliases in the shell. One common example is the ls command in Linux. Typically it has params tacked on for formatting the output so that you just have to type
    ls filepattern
    in the shell command prompt.

    You can do similar stuff with .cmd files.
    for example,
    chrome.cmd file with
    c:\program files\chrome\chrome.exe --param1 --param2 %*
    (the %* means to substitute the entire command tail. Any urls will be passed to chrome)
    That said, how do I make this cmd a default? The issue is that I need a consistent way of opening chrome with these parameters that will be the system default.

    As far as I understand, using a .cmd like so will simply accomplish what a shortcut otherwise would. That's all well and good if I click the cmd (or a shortcut to it) in order to open it - but I basically want to set it so anytime the system would feel compelled to open chrome.exe, it will instead open chrome.exe with these parameters.

    For instance, skype needs this to open chrome properly by default, otherwise, it just opens a chrome window without the parameters. The closest I've gotten is hacking the registry file entries for things like .html so that the program it points to is chrome.exe --user-data-dir, etc. Like so:

    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    
    [HKEY_CLASSES_ROOT\FTP\SHELL\OPEN\COMMAND]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    
    [HKEY_CLASSES_ROOT\http\SHELL\OPEN\COMMAND]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    
    [HKEY_CLASSES_ROOT\https\SHELL\OPEN\COMMAND]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    
    [HKEY_CURRENT_USER\Software\SHELL\Classes\FTP\shell\open\COMMAND]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    
    [HKEY_CURRENT_USER\Software\SHELL\Classes\http\shell\open\COMMAND]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    
    [HKEY_CURRENT_USER\Software\SHELL\Classes\https\shell\open\COMMAND]
    @="\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --user-data-dir=D:\\Chrome \"%1\""
    However, when I use CCleaner, or the program updates, or just something screwy happens, this all breaks down. Basically, what I'm trying to accomplish is this:

    1. Click chrome or link from IM
    2. OS receives call to open this application
    3. Instead of opening just CHROME.exe, the OS call results in one of two things:
    3a. It recognizes the exe as binded to --user-data-dir (etc.) or
    3b. It calls "chrome.exe" which redirects to the real chrome.exe with these parameters, sort of like a shortcut
    4. Chrome opens by default in all instances (exempting special shortcut parameters for other circumstances) with these parameters.
      My Computer


  6. Posts : 5,092
    Windows 7 32 bit
       #6

    If you make the .cmd the "system default" how would you then launch chrome.exe without entering an endless loop? If chrome.exe is going to be called using the full path from myriad programs, then there is no smooth way I know of to accomplish it.

    Either that or see if there's a Windows replacement shell available that supports aliases.
    Also I'd ask on the chromium groups(used to be on google groups but has moved to its own server.)
      My Computer


  7. Posts : 5,092
    Windows 7 32 bit
       #7

    One could use the approach of renaming the exe to something like chrome_real.exe and call that from the .cmd if it wasn't for the multiple exe launch chrome uses. It would work with firefox as it only has one exe in memory at a time. chromium discussion group may have some better ideas. I'm sure people are sticking on the params in some automated fashion.
      My Computer


  8. Posts : 29
    Win7 Home Premium 64x
    Thread Starter
       #8

    I don't quite think what I'm looking to do has been understood. I opted to use my original plan of writing a .exe and replacing the chrome file. That way it will call the same, but the actual application will open as it should.
      My Computer


  9. Posts : 1,711
    Win 7 Pro 64-bit 7601
       #9

    Registry edits and making an exe won't work in the long run as when the damn thing updates (and it does it silently witout giving you any warning, as most google stuff) it's going to return like default situation.

    I still don't understand why you don't want to do symbolic links. They work fine and will keep working even in case it updates as it is a system-level change, fully invisible to applications.

    I think the only way to get it to work like you need it without symlinks or black magic is to get it to run in its own virtual environment, but a full blown virtualbox is a bit unwieldy.
    I think that Sandboxie might be what you are looking for and it allows any program to do what you ask (run with all its stuff in a single place). Also PortableApps have a portable version of Chrome (that again runs in its own folder without writing stuff anywhere else. The same concept Sandboxie uses, keeping apps locked down in their own little semi-virtual environment), but I don't know if it is able to be set as the default broswer (but in this case a registry edit and/or making a fake exe pointing to it will work fine as any Chrome update is done inside its little box anyway).

    Neither should have any impact on performance unless your processor is an Atom.
    Last edited by bobafetthotmail; 29 Jun 2013 at 08:01.
      My Computer


  10. Posts : 29
    Win7 Home Premium 64x
    Thread Starter
       #10

    Pity. Linux has so many fun things to do but none of the critical functionality I need.

    Yea, I'm probably stuck using MKLINK. I kind of figured that out after I accidentally my user profile.

    Edit: MKLINK doesn't hold up in a ramdisk. At any rate, I tested it and for the purposes and trouble I've been through the results are simply not there. It loads no faster than my browser can display the page to begin with, so.... HDD or RAM doesn't matter.
    Last edited by ThelastCanadian; 29 Jun 2013 at 23:51.
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:59.
Find Us