It's kind of tricky but very easy to do. This example would allow you to open a certain type of file (*.test) up with a program (Notepad++) that resides in a user specific directory. I used this for a scenario on my Windows 2008 server running Remote Desktop (AKA Terminal Server) to allow each user to use a program installed PER user account so that different settings could be used per user (ex: *.ini files located within the apps directory). Note: Not that it matters but the folder "programs" is hidden so the users do not see it.
Paths:
Application (notepad++): Y:\%username%\programs\Notepad++\notepad++.exe
File To Open (File.test): Y:\%username%\TestFiles\File.test
Step 1. IF you are using mandatory profiles be sure to change the NTUSER.MAN file back to NTUSER.DAT.
Step 2. Log into the profile you wish to edit using Remote Desktop Client.
Step 3. Open up regedit and delete the following keys if they exist.
HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.test
Step 4. Create a new text file and name it "original.reg". Fill it with the following...
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=""
Step 5. Refresh registry (F5) and look for the new key. Should see the "command" key with "(Default)" value blank. In the "command" key add a new "Expandable String Value" called "New Value #1". Set the value to the application's path "Y:\%username%\programs\Notepad++\notepad++.exe" "%1". Then export the "command" key to the desktop as "expanded.reg".
Step 6. Edit the "expanded.reg" file in notepad and copy all the data after the "New Value #1". Ex: =hex(2):22...
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=""
"New Value #1"=hex(2):22,00,59,00,3a,00,5c,00,25,00,75,00,73,00,65,00,72,00,6e,00,\
61,00,6d,00,65,00,25,00,5c,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,\
6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,22,\
00,20,00,22,00,25,00,31,00,22,00,00,00
Step 7. Close expanded.reg file and open the "original.reg" file then replace the default command (that is empty "") with the new hex value we have in our clipboard. The file "original.reg" should look like the following now...
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=hex(2):22,00,59,00,3a,00,5c,00,25,00,75,00,73,00,65,00,72,00,6e,00,\
61,00,6d,00,65,00,25,00,5c,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,\
6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,22,\
00,20,00,22,00,25,00,31,00,22,00,00,00
Step 8. Now that we have our expanded variable ready to go lets just add an extension to associate with the application. Add the following to the "original.reg" file making it look like the following...
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open]
[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=hex(2):22,00,59,00,3a,00,5c,00,25,00,75,00,73,00,65,00,72,00,6e,00,\
61,00,6d,00,65,00,25,00,5c,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,\
6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,22,\
00,20,00,22,00,25,00,31,00,22,00,00,00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test\OpenWithList]
"a"="notepad++.exe"
"MRUList"="a"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test\OpenWithProgids]
"Notepad++_file"=hex(0):
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test\UserChoice]
"Progid"="Applications\\notepad++.exe"
Step 9. Open up regedit and delete the following keys if they exist. (Yes do it again)... Now the registry is like we never did anything and we have a registry file ready to insert into the registry!
HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.test
Step 10. If you want to apply this to the current profile then RUN THE REGISTRY FILE "original.reg" and insert it into the registry.
And that's it! Now all *.test files will open up with "Y:\%username%\programs\Notepad++\notepad++.exe". Go check the registry and see the new default entry.