/build/static/layout/Breadcrumb_cap_w.png

placing a tilde in a registry value

hi guys..

i have a registry value i'm trying to place in my project.. a path variable.. but it wont accept the usual "c:\program files\myapp" when i actually run my application.. i have to change it to "c:\progra~1\myapp" for it to function correctly.. how do i do this in my current project so when it installs it writes "c:\progra~1\myapp" instead of the full path? i'm using wps

thanks in advance.. =)

rick

0 Comments   [ + ] Show comments

Answers (24)

Posted by: GB1 18 years ago
Orange Belt
0
Hi,

The only solution I can think is (assuming you are delivering a file in your package to the path you need in the registry) to use the component path for the file. By using a ! prefix it will use the full short path to the location of the component - the actual file name is not included inthe path.

example:

[!myappexe.exe]


Graham
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
I think you may find that this information is slightly incorrect Graham?

Using the "!" character only works on the file key to my knowledge - not the component key (although these may often be the same). Using the file key may return a short path (assuming the tables have been populated correctly), but it will also return the file name on the end.

You may require a CA to accomplish what you're trying to do.

By the way, what do you mean by "path variable"? I'm assuming this is a simple registry key despite this ambiguous use of terminology?
Posted by: MSIMaker 18 years ago
2nd Degree Black Belt
0
The way I have done it in the past is to use [ROOTDRIVE]

So put in [ROOTDRIVE]Progra~1\Appname

Wise will accept this without changing it to long filename format.
Posted by: GB1 18 years ago
Orange Belt
0
ORIGINAL: WiseUser

I think you may find that this information is slightly incorrect Graham?

Using the "!" character only works on the file key to my knowledge - not the component key (although these may often be the same). Using the file key may return a short path (assuming the tables have been populated correctly), but it will also return the file name on the end.

You may require a CA to accomplish what you're trying to do.

By the way, what do you mean by "path variable"? I'm assuming this is a simple registry key despite this ambiguous use of terminology?




Fair enough, your version sounds better - sorry, I was working from memory.

I assumed that it was soemthing he wanted to keep as a variable though. Like you say you might need a bit of script to sort this one out.
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
I wouldn't recommend using the ROOTDRIVE property, as this may not resolve to the drive where program files resides - you might end up with "D:\Progra~1\AppName" in the registry.

Besides, it's not good practice to hard-code paths. If someone decides to change the value of INSTALLDIR, the application should still work - it won't if you hard code things.

I'm pretty sure that a CA is the only good option.
Posted by: GB1 18 years ago
Orange Belt
0
ORIGINAL: WiseUser

I wouldn't recommend using the ROOTDRIVE property, as this may not resolve to the drive where program files resides - you might end up with "D:\Progra~1\AppName" in the registry.

Besides, it's not good practice to hard-code paths. If someone decides to change the value of INSTALLDIR, the application should still work - it won't if you hard code things.

I'm pretty sure that a CA is the only good option.






For what it's worth I agree with quote above and appologise again for my duff info - next time I post I will double check my info.

I had confused prefixes you CAN use with filekeys and those you cant with components. Even with the file key it will include the filename as WiseUser correctly said.

For reference the stuff I talking about is here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/formatted.asp
Posted by: MSIMaker 18 years ago
2nd Degree Black Belt
0
ORIGINAL: WiseUser
I wouldn't recommend using the ROOTDRIVE property, as this may not resolve to the drive where program files resides - you might end up with "D:\Progra~1\AppName" in the registry.

Besides, it's not good practice to hard-code paths. If someone decides to change the value of INSTALLDIR, the application should still work - it won't if you hard code things.

I'm pretty sure that a CA is the only good option.


While I agree that you shouldnt hard code paths...he did ask for C:\Program Files and so I'm assuming his app will never see a server.

btw if he is running multiple partition machines and he doesnt have ROOTDRIVE set then he will one day end up with apps on the other drives anyway, once C: starts to fills up.
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
Hi Jim,

I'm only quoting best practise - what Rixk2 finally does is up to him. Depending on his personal situation, "best practise" may not be the best way forhim to proceed. Creating a CA to solve this issue correctly without hard-coding anything might be overkill if he knows that the INSTALLDIR will never change in his envionment. However, using "ROOTDRIVE" would be worse than hard-coding the path because it may resolve to a totally different drive.

The "ROOTDRIVE" property will not affect which drive packages are installed to if they are installed under "ProgramFilesFolder" - only if they are installed to a root folder. So in this particular case, the application will always go to drive "C".

And may I be the first to congratulate you on 500 posts!!
Posted by: rikx2 18 years ago
Purple Belt
0
hi guys.. sorry for this very late reply. i have been called away to work on another project (repackage another application =)

here's another thing that came up and is very connected with my original post..

how do i append my program directory to the value of Path in the Environment Variables and write it out like this
"existingpaths;c:\myprog~1;c:\myprog~2"

my path usually ends like this
"existingpaths;c:\myprogam directory1;c:\myprogam directory2"

i'm thinking of using vbscript for this but i wont till i get some feedbacks from you guys =)

thanks very much for the replies.. i really appreciate the help, feedbacks and suggestions

rick =)
Posted by: rikx2 18 years ago
Purple Belt
0
btw.. c:\myprogra~1 and c:\myprogra~2 is actually [INSTALLDIR] and so.. i'm not placing hardcoded directories on my project.. =)

thanks again
rik
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
Use the "Environment" table.

Add a new row as follows:

Environment column: "Path"
Name column: "*=-Path"
Value column: "[~];[INSTALLDIR]"

Remove the quotes of course.[;)]

For details, read the SDK at the following location:

http://msdn.microsoft.com/library/en-us/msi/setup/environment_table.asp
Posted by: GB1 18 years ago
Orange Belt
0
ORIGINAL: WiseUser

Use the "Environment" table.

Add a new row as follows:

Environment column: "Path"
Name column: "*=-Path"
Value column: "[~];[INSTALLDIR]"

Remove the quotes of course.[;)]

For details, read the SDK at the following location:

http://msdn.microsoft.com/library/en-us/msi/setup/environment_table.asp



Hi WiseUser,

Maybe you can assit me with your advice above too.

I have sucessfully used the [~] to apend to envrionment variables (well the PATH specifically) before. However, according to

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/registry_table.asp

you can also use the [~] in a registry value. My understanding is if you preceed a string value with [~] it will append the string value to the end of the exisiting string value. However I have never made this work in practice - the result if I remember correctly is the value is deleted all together!

Have you ever tried this with a good result?
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
If you're thinking what I'm thinking you're thinking - be careful!!

The "Path" environment variable is a registry key, but it must be of type "REG_EXPAND_SZ" in order to work correctly.

If you try writing to this key using the registry table as you appear to be suggesting, you might accidentally change the type.
Posted by: GB1 18 years ago
Orange Belt
0
ORIGINAL: WiseUser

If you're thinking what I'm thinking you're thinking - be careful!!

The "Path" environment variable is a registry key, but it must be of type "REG_EXPAND_SZ" in order to work correctly.

If you try writing to this key using the registry table as you appear to be suggesting, you might accidentally change the type.



No, I wasn't thinking of writing to the path via the registry, it was a different question altough related to your response I quoted, in terms of using [~] to append.

It seems to be documented (see my link above), but I have never made it work and wondered if it was just me.

My quick fix was to use a system search and use the property as a way of appending a registry value in my MSI. Both my work around and the use use of the [~] (if it does work) suffer from the downside neither checks to see if the value already exists in the string however.

In short am I correct in saying that appending a registry value, only with a value that doesn't already exisit in the value string, requires a custom action?
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
Btw, I think what you have experienced in the past can be explained as follows.

The existing key is of type "REG_SZ". Your new key is considered to be of type "REG_MULTI_SZ". Because they're not the same type, the "REG_SZ" key is overwritten with the new "REG_MULTI_SZ" one.

If the original key had been a "multi string" one, the value would have been appended.

Hope this makes sense?[:D]
Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
0
Unless the registry in question happens to represent an environment variable, or is of type "REG_MULTI_SZ", I guess the short answer must be "yes".
Posted by: rikx2 18 years ago
Purple Belt
0
hi guys.. thanks for the replies..
i have no problem appending to the existing path variable.. but what i was trying to do is instead of appending the full path of my app directory "c:\program files\myapp" it should append as "c:\progra~1\myapp"


thanks very much... you guys are great =)

rick
Posted by: MSIMaker 18 years ago
2nd Degree Black Belt
0
ORIGINAL: WiseUser

And may I be the first to congratulate you on 500 posts!!



Thanks alot...I hadnt noticed myself.....500 posts came around pretty quickly . I better get back to work before my boss finds out :)

btw...let me pass my congrats to you as well for 200 posts...wd and thanks for all the help.
Posted by: MMA 18 years ago
Senior Yellow Belt
0
Hi rikx2,

Remember.. Everything you cant do in MSI, you can script yourself out of... I have had the same problem with Notes, so what i did was making an embedded VBscript in the "execute immidiate" sequece, witch converted the property [INSTALLDIR] (C:\Program Files\Lotus\Notes) to a 16 bit Value string (C:\Progra~1\Lotus\Notes) and wrote the new value to the registry... I dont have the script now.. but hope it can lead u in the right direction.
Posted by: Deployee 16 years ago
Yellow Belt
0

I just realized that I am replying back to a very old post but perhaps someone will still be able to help.
I would like to append to a registy key //HKey_LocalMachine/software/microsoft/windows/currentversion
the key is called DevicePath, I would like to append to it and remove it if the program is uninstalled.
I have tried the methods mentioned in your posts regarding placing a tilde in the a registry value from 5/2005 but have not had luck.
Environment variable doesn't work because the key I am referring to is = not an environment variable and I am not having luck using the tilde and registy entry but perhaps I am not doing it correctly.
in my wsi I have 15 files getting copied locally and one registry entry
Currently I have the path and key name under destination computer and my key value is set to: [~];%systemdrive%\PnPdrvers\Merlin
All this seems to do is add a key under Hkey Current User/Environment
Any thoughts or advice would be great.
Thanks!
Posted by: knight 16 years ago
Orange Senior Belt
0
Hi rikx2,

Tama si MMA, kung hindi mo magawa sa ordinaryong Custom Action (may condition) or Property Value. Mas magandang gawin mo nalang sa vbscript, dyan ka naman malupit eh.

knight [8D]
Posted by: anonymous_9363 16 years ago
Red Belt
0
Currently I have the path and key name under destination computer and my key value is set to: [~];%systemdrive%\PnPdrvers\Merlin
All this seems to do is add a key under Hkey Current User/Environment
You have the correct format for appending to a registry value. Something somewhere is pointing to the wrong key. Run your MSI with verbose logging: that should highlight what's going wrong.
Posted by: anonymous_9363 16 years ago
Red Belt
0
Tama si MMA, kung hindi mo magawa sa ordinaryong Custom Action (may condition) or Property Value. Mas magandang gawin mo nalang sa vbscript, dyan ka naman malupit eh.With the greatest respect, if this is a response with a solution, it would be of universal use for it to be in English, as this is (self-evidently) a predominantly English forum. If it's a private message, maybe a PM/email would have served better?
Posted by: xythex 16 years ago
Orange Senior Belt
0
I just realized that I am replying back to a very old post but perhaps someone will still be able to help.
I would like to append to a registy key //HKey_LocalMachine/software/microsoft/windows/currentversion
the key is called DevicePath, I would like to append to it and remove it if the program is uninstalled.
I have tried the methods mentioned in your posts regarding placing a tilde in the a registry value from 5/2005 but have not had luck.
Environment variable doesn't work because the key I am referring to is = not an environment variable and I am not having luck using the tilde and registy entry but perhaps I am not doing it correctly.
in my wsi I have 15 files getting copied locally and one registry entry
Currently I have the path and key name under destination computer and my key value is set to: [~];%systemdrive%\PnPdrvers\Merlin
All this seems to do is add a key under Hkey Current User/Environment
Any thoughts or advice would be great.
Thanks!


I would want to use a vbscript in a Custom Action in the Execute Deferred table. The problem you will run into is not so much appending the value, but more so to remove it on uninstall, since you do not know what else might modify this key between your install and uninstall. Create a VBScript to read the value, append your value, and write it back on install. Then create a seperate VBScript to read the value, parse the string, remove your entry, and write the updated string back on uninstall.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ