Change start -> run -> chrome to include switches - windows

I've looked around the internet for a way to use Windows's Windows+R shortcut to run chrome (or any app) with with default command-line switches.
My wife and I share a Windows User, but in Chrome, we have separate users so we don't have to share settings, bookmarks, etc.
Chrome has a switch --profile-directory="[someDir]" that will allow you to set the user when it's run. I'm the only one who uses the Windows+R shortcut, so I'd like to set the default setting, when I type "chrome", to run a chrome instance with my user, regardless of the last chrome window opened (which is how it decides which user to run).
It looks like the right place to make this change is in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
If I edit the (Default) key to include --profile-directory="Default", Windows can't find the path, presumably because it puts quotes around the whole thing when I press enter on the Run dialog box.
Using something akin to SQL Injection and adding strategically placed quotes doesn't work either--my guess is that it escapes them.
MSDN hints that you might be able to add command-line parameters as subkeys to the ...\App Paths\chrome.exe key, but I tried adding --profile-directory = "Default", --profile-directory= = "Default", and --profile-directory="Default" = (empty string), none of which worked.
Anyone know how to do this, or are perhaps better at Google than I am?
As a last resort, I can replace the (Default) reg key to point to a batch file that runs chrome.exe with the switch, but I would really rather not.

It seems that you need to use the internal Chrome profile name.
I'm running ChromePortable, so the first thing I had to do was change the user-data-dir
chrome://version helps confirm the profile in use....
At first I thought a full path was required. Actually, it's just the internal name that's referenced...
Here's an example of my revised Chrome shortcut
L:\OS\MyApps\GoogleChromePortable\App\Chrome-bin\chrome.exe --user-data-dir=L:\OS\MyApps\GoogleChromePortable\Data\profile --profile-directory="Profile 1"
(as always, re command args, any spaces should be surrounded by quotes)

Related

FTYPE/ASSOC priority and adding to OpenWithList from the command line

(Not sure if this belongs on superusers, but it seems there is a cmd.exe tag here, so here goes...)
As background, I'm working on a Firefox add-on (This question does not require knowledge of Firefox, btw, as Firefox add-ons can call the command line.) The add-on aims to build different kinds of shortcuts to cmd.exe (especially for the sake of my project https://github.com/brettz9/webappfind which allows files to be opened directly from the desktop into web apps).
Anyways, I'd like to give users the option to associate these shortcuts:
As the default handler for specific file extensions or file types.
To show up within the Open With list of applications (even if the user opts not to make the apps as default handlers)
As far as the default handling, I have found the ftype and assoc (and associate) commands, but I have read that user selections will override their behavior. Is there some way to ensure that I can get priority from the command line in associating file extensions to types and specific executables (until the user changes it again), or if it is not possible, then at least through C++ or the like?
As far as the Open With list:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<file extension>\OpenWithList
...in my testing (with an exe), this command:
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.svg\OpenWithList /v d /d D:\wamp\www\webappfind\cplusplus\WebAppFinder-view-mode-Firefox.exe
...did cause the exe file to show up in:
reg query HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.svg\OpenWithList
...but it did not show up when I subsequently right-clicked a file with the ".svg" extension.
I would really appreciate any help with these two points.
REGEDIT4
[HKEY_CURRENT_USER\Software\Classes\Applications\MYFOO.exe\shell\open\command]
#="\"C:\\MYFOO.exe\" \"%1\""
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.myfoo]
"Application"="MYFOO.EXE"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.myfoo\OpenWithList]
"a"="MYFOO.EXE"
"MRUList"="a"
So I got to an investigation what makes those file associations. It appears that you have to create a mapping from the bare EXE name to the full path as shown in the first two long-ish lines. Then you must only use the EXE name in the .extension branch. Setting the .extension's Application value will give you your default app instantly. Remember, only use APP.EXE, its full path must be defined as above. This was your main error. The "%1" part allows you to customize the parameters of your program so that it doesn't have to be just the opened document in quotes, as shown here. The backslashes are just escape characters for Regedit, you may discard them as you see fit.
The OpenWithList is tricky in the sense that there are letters for entries and just a blind write may overwrite some of the user's favorite apps. One approach would be to call your item "z" to lower the probability of overwriting. The right way would be enumerating the key and giving your app the first free letter. The MRUList is not essential, although it should have each used letter once and yours bumped to the start.
Note about user friendliness: Explorer will cache these values until next reboot. Make sure you update the registry and place exe first and create your file later. Although the caching only fully influences the display of the file and when it is run, the registry is read again and it will execute as you want.
TIP: If you decide to use Regedit instead of reg, the /s parameter skips the confirmation message and applies the values right away. Make sure you use double backslashes in the full path as shown. When preparing your temporary .reg file, make sure you append two CRLF's to the end or a glitch may cause your last line of code to be ignored. This sample starts with REGEDIT4 which signifies an ANSI file. If you need support for Unicode in your app path, you'll have to start the file with Windows Registry Editor Version 5.00 and store it in UTF16. This is already a superior solution to calling reg because there's no way you could get CMD.EXE to process special UTF stuff through the command line without mangling.

Passing arguments while launching program from browser

I am trying to launch an application (.exe) from my browser.
The specific app needs 4 arguments/parameters when launching, which are: firstname, lastname, id, info
Is there a way to add these arguments on the Internet Explorer address bar when i launch my program?
I mean something like this:
"myapp:// -firstname -lastname -id -info"
(I only managed to add those arguments straight to the windows registry, it worked that way. But thats no help... i need them to be inputted when launching the app )
I have added this to my windows registry:
[HKEY_CLASSES_ROOT\myapp]
#="URL:myprogram Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
#="\"C:\\myapp.exe\""
[HKEY_CLASSES_ROOT\myapp\shell]
[HKEY_CLASSES_ROOT\myapp\shell\open]
[HKEY_CLASSES_ROOT\vsa\shell\open\command]
#="\"C:\\myapp\" "%1"
Thanks for help already! I hope someone knows how to fix this... :)
ps. Im using windows 7 64 bit and Internet Explorer 10.
You cannot simply pass multiple command line arguments to your application (unless they're listed explicitly in the registry as you've shown).
Instead, you must code your application's executable so that it is able to process the Application Protocol URL string. So your code is invoked by the browser like so:
C:\apps\myapp.exe "myapp:myParam?myParam2&myParam3&myParam4"
The executable must be able to process this string and handle it appropriately. You must take care to avoid security holes in the parsing of this string, as ANY webpage could exploit a hole here to escape the browser sandbox and attack the user's system.
There's more information on Application Protocols in this post: http://blogs.msdn.com/b/ieinternals/archive/2011/07/14/url-protocols-application-protocols-and-asynchronous-pluggable-protocols-oh-my.aspx

How to change the path for "run command" "notepad"?

Where is in the registry the path executed when I run the "notepad" command in windows "Start->run command" interface? I want to change it for notepad++ (it is required so, although could look not really good)
If you are like me you use windows run command all the time. I hate using the mouse to point and click a shortcut on the start menu. WIN-R are probably the two most over used keys on my keyboard. After thinking about if awhile I hunted down how the run command works. It turns out that it makes a call to ShellExecute, which I guess is not too surprising. The next thing I wanted to find out was exactly how the commands are resolved. The following is an ordered list of how they are resolved ([1]):
The current working directory
The Windows directory (no subdirectories are searched)
The Windows\System32 directory
Directories listed in the PATH environment variable
The App Paths registry key
Naturally the next thing I wanted to do was customize existing commands or add new commands so I do not have to type as much (standard lazy approach). After examining my options which were to put the executable in one of those paths (since it only locates executables and not shortcuts), modify the path environment variable or add a key to App Paths. The App Paths option seems to be the easiest and most flexible to me. Here is a layout of what you need to do to add an App Paths entry ([1]):
HKEY_LOCAL_MACHINE-->
SOFTWARE-->
Microsoft-->
Windows-->
CurrentVersion==>
App Paths-->
file.exe-->
(Default) = The fully-qualified path and file name
Path = A semicolon-separated list of directories
DropTarget = {CLSID}
Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. I cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.
The minimum needed to add a new entry is to add the key file.exe where file is the string you want to type into the run command and to add the Default entry which is the fully-qualified path to the file you want to execute. Note that even it the file you are going to reference isn't an exe file you still need to put the .exe on the key. Here is a sample registry file that I created to add a shorter keyword for Internet Explorer:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\ie.exe] #="C:\Program Files\Internet Explorer\iexplore.exe"
After entering that entry into the registry I can simply type “ie” at
the run command to open internet explorer.
Here is a list of some common commands I use at the run command:
cmd – Command prompt winword – Microsoft Word excel – Microsoft Excel
outlook – Microsoft Outlook iexplore – Internet Explorer firefox –
Mozilla Firefox notepad – Notepad compmgmt.msc – Computer Management
Console control appwiz.cpl – Add/Remove programs dialog mstsc –
Microsoft Terminal Service Client regedit – Registry Editor
…
If there is some program that I find myself using all the time I figure out what the run command is for it and if there is not a short easy one I add one to my App Paths as described above. Does anyone else have some other common run commands they use?

Right Click in Windows Explorer

I have been trying to add context based right click in windows explorer for a file of extension L5X. I have tried HKEY_CLASSES_ROOT\l5xfile\Shell\convert\command and set the (Default) key value to the program I want to have open the file. (I want it to say "Convert" on the context menu) My first issue seems to be that in .NET (even when running elevated) I cannot change the Default key's value. My other issue is changing that Default key value doesn't do anything to the context menu. I would really prefer a no reboot required solution.
Also, I really need this to work on WinXP all the way up to Win7 (including Server 2003, 2008 and 2008R2). If I need to detect OS and do things differently for different OSes, I will but I'm really stuck here.
PS, I tried the solution found here with no luck.
You need administrator rights to write to HKEY_CLASSES_ROOT, HKEY_CLASSES_ROOT is a merged view of HKEY_LOCAL_MACHINE\SOFTWARE\Classes and HKEY_CURRENT_USER\Software\Classes. If you want to install it for just the current user, write to HKEY_CURRENT_USER\Software\Classes
\l5xfile\Shell\convert\command might not be the correct path, when windows looks for context menu entries for a filetype, it first looks in HKEY_CLASSES_ROOT\.EXT, then uses the default value it finds there: HKEY_CLASSES_ROOT\%defaultvaluefrom.EXT%\Shell\*
XP added a new key HKEY_CLASSES_ROOT\SystemFileAssociations designed for non-primary actions where you don't care about the ProgId/Class (The l5xfile part)
MSDN documents all these registry paths and settings, see: File Types and Verbs and File Associations

How to determine the Windows default browser (at the top of the start menu)

How can I determine the Windows default browser (at the top of the start menu)?
I am using VB6 but can probably adapt other code no problem.
There are similar questions on Stack Overflow, but they seem to provide incorrect answers.
For instance the key HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\ lists both Internet Explorer and Firefox on my PC.
And getting the .html association fails for me as well, as HTML files are associated with IE but Firefox is my default browser.
Note that I don't want to actually open the browser, just get it's name.
When you click on a .html file, the browser that opens it is the one that has registered the .html extension.
When you open a http:// link (e.g. by typing it into the "Start->Run" box), the browser that opens is the one that has registered the HTTP protocol (although it's usually the same browser in both cases).
Whatever is displayed in Start Menu is not related to this.
HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\(Default) is the current user's handler for the HTTP protocol (which means "default browser"; NOTE: this is NOT the same thing as the .html default handler!).
However, it is possible to have a different browser at the top of Start Menu without changing the default. FYI, the browser executable name in Start menu is stored in HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default).
Tested in Windows 7 x64:
This is a two step process. The user's default browser is in key:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid
Common browser Key Name:
IE: IE.AssocFile.HTM
FireFox: FirefoxHTML
Chrome: ChromeHTML
Opera: Opera.HTML
Replace <KEY NAME> below with one of the values above to find the executable:
HKCR\<KEY NAME>\shell\open\command
Autohotkey script to display the default browser path and executable:
MsgBox % "Default browser: " Browser()
Browser()
{
; Find the Registry key name for the default browser
RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid
; Find the executable command associated with the above Registry key
RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command
; The above RegRead will return the path and executable name of the brower contained within qoutes and optional parameters
; We only want the text contained inside the first set of quotes which is the path and executable
; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
StringGetPos, pos, BrowserFullCommand, ",,1
; Decrement by one for the StringMid to work correctly
pos := --pos
; Extract and return the path and executable of the browser
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
Return BrowserPathandEXE
}
Default browsers are usually set on a per user basis. Have you tried HKEY_CURRENT_USER instead? Shows up on mine under there correctly.
reg QUERY HKEY_CLASSES_ROOT\htmlfile\shell\open\command /ve
you'll get something like
HKEY_CLASSES_ROOT\htmlfile\shell\open\command
(Default) REG_SZ "C:\Program Files\Internet Explorer\iexplore.exe" %1

Resources