shorterxp Posted August 3, 2018 Posted August 3, 2018 (edited) Hi, I would like to store environment variable %programfiles% in a registry key, to replace the default which specifies absolute path.. One solution here suggests navigate to existing key, create a new REG_SZ_EXPAND there, then enter desired text, in my case %programfiles%\...\.exe. Once entered, export the key and the result is converted to HEX: @=hex(2):25,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,66,00,69,00,6c,00,65,\ 00,73,00,25,00,5c,00,78,00,6d,00,70,00,6c,00,61,00,79,00,5c,00,74,00,75,00,\ 6e,00,65,00,2e,00,69,00,63,00,6f,00,00,00 When I delete key and apply this export, a single % appears in the key. I know for a fact that if I enter the %programfiles%\...\.exe. string as an REG_SZ_EXPAND, the associated program opens normally. Not sure what I did wrong regarding the single % appearing. Any pointers? Edited August 3, 2018 by shorterxp
shorterxp Posted August 3, 2018 Author Posted August 3, 2018 (edited) Got it to work using REG ADD "HKCR\app\DefaultIcon" /v (Default) /t REG_EXPAND_SZ /d "%programfiles%\app\tune.ico,0" Although I would have preffered to use import registry method.... Edited August 3, 2018 by shorterxp
jaclaz Posted August 3, 2018 Posted August 3, 2018 Which OS is that? This: Quote Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\zztest] @=hex(2):22,00,25,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,66,00,69,00,6c,\ 00,65,00,73,00,25,00,5c,00,61,00,70,00,70,00,5c,00,74,00,75,00,6e,00,65,00,\ 2e,00,69,00,63,00,6f,00,22,00,00,00 Works just fine on my XP if imported via Regedit. jaclaz
shorterxp Posted August 3, 2018 Author Posted August 3, 2018 (edited) Could be that I used REGEDIT4 not 5.0 Edit: precisely the problem was I used REGEDIT4 not 5.0 Thanks Jaclaz once again Edited August 3, 2018 by shorterxp
jaclaz Posted August 3, 2018 Posted August 3, 2018 23 minutes ago, shorterxp said: Could be that I used REGEDIT4 not 5.0 Edit: precisely the problem was I used REGEDIT4 not 5.0 Thanks Jaclaz once again You are welcome , for the record Regedit 4 format is NOT Unicode (while 5 is): https://msfn.org/board/topic/47769-regedit4-vs-windows-registry-editor-v-5/ jaclaz
Mcinwwl Posted August 9, 2018 Posted August 9, 2018 On 8/3/2018 at 6:06 PM, shorterxp said: Got it to work using REG ADD "HKCR\app\DefaultIcon" /v (Default) /t REG_EXPAND_SZ /d "%programfiles%\app\tune.ico,0" Although I would have preffered to use import registry method.... Sorry to hop in, but I tried to understand similar things just today... Shouldn't %programfiles% be enclosed within %%double percents%%? And if not, why? I'm asking based on what worked for me... cmd sand .reg still seems to me more a set of exceptions than rules
shorterxp Posted August 10, 2018 Author Posted August 10, 2018 Thats what typically works for windows XP. It can change between OS. I think M$ make an effort to make sure old installs that use either work regardless.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now