Jump to content

Variable as REG_SZ_Expand wont stay


Recommended Posts

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 by shorterxp
Link to comment
Share on other sites


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 by shorterxp
Link to comment
Share on other sites

Which OS is that? :unsure:

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

 

 

 

Link to comment
Share on other sites

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 :P

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...