Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Redirecting filepaths or binding paraameters to an EXE

27 Jun 2013   #1
ThelastCanadian

Win7 Home Premium 64x
 
 
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 System SpecsSystem Spec
.
28 Jun 2013   #2
bobafetthotmail

Win 7 Pro 64-bit 7601
 
 

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.

Quote:
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 System SpecsSystem Spec
28 Jun 2013   #3
ThelastCanadian

Win7 Home Premium 64x
 
 

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 System SpecsSystem Spec
.

28 Jun 2013   #4
MilesAhead

Windows 7 32 bit
 
 

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)
My System SpecsSystem Spec
28 Jun 2013   #5
ThelastCanadian

Win7 Home Premium 64x
 
 

Quote   Quote: Originally Posted by MilesAhead View Post
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 System SpecsSystem Spec
28 Jun 2013   #6
MilesAhead

Windows 7 32 bit
 
 

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 System SpecsSystem Spec
28 Jun 2013   #7
MilesAhead

Windows 7 32 bit
 
 

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 System SpecsSystem Spec
28 Jun 2013   #8
ThelastCanadian

Win7 Home Premium 64x
 
 

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 System SpecsSystem Spec
29 Jun 2013   #9
bobafetthotmail

Win 7 Pro 64-bit 7601
 
 

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.
My System SpecsSystem Spec
29 Jun 2013   #10
ThelastCanadian

Win7 Home Premium 64x
 
 

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.
My System SpecsSystem Spec
Reply

 Redirecting filepaths or binding paraameters to an EXE




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Binding gamepad key to a keyboard (as opposed to the usual vice-versa)
Hello, I have the odd requirement of needing to bind a gamepad key to a keyboard. I have an Xbox controller for PC. hen I hit "F2" on my keyboard I need it to simulate hitting "back" on the Xbox controller. Thanks for any help :)
Hardware & Devices
Most links redirecting to ads
So, this problem appeared a few days ago - firstly windows started alerting me that an application I didn't recognise was crashing every 5 minutes. A quick check and it turned out to be a (Pretty poorly coded if you ask me) trojan which kept crashing. MBAM swiftly removed it, however I've noticed...
System Security
Redirecting Folders in 7
I want to move some of my program folders off of my system disk onto a raid 0 disk, for performance's sake. This was easier to do in past Windows OSs, not so much now. Any clues? I am using Windows 7 HP, and the installs do not offer a choice of directory. :cry:
Performance & Maintenance
Assembly binding issue stops Connectify from running?
Thank you for taking the time to look at this. I am totally stumped. I seem to only have this issue when trying to use "Connectify". Connectify is a windows 7 only program that allows you to create a Wifi access point using software and Windows 7. I also noticed that when I boot my...
Software
Binding a key to a shortcut
I want to bind a kind to a shortcut (icon, like a shortcut to a game) specifically the key that minimises all windows. I have show desktop, but as I understand it brings up a seperate pane with the desktop over existing windows instead of minimising them and as such doesn't show ObjectDock. Is...
Customization


Our Sites

Site Links

About Us

Find 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 15:27.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App