Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
shorterxp

Variable as REG_SZ_Expand wont stay

Recommended Posts

Posted (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 by shorterxp

Share this post


Link to post
Share on other sites

Posted (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 by shorterxp

Share this post


Link to post
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

 

 

 

Share this post


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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×