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
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)
Please log in to answer
Posted by:
GB1
19 years ago
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
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
19 years ago
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?
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
19 years ago
Posted by:
GB1
19 years ago
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
19 years ago
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.
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
19 years ago
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
19 years ago
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
19 years ago
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!!
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
19 years ago
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 =)
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
19 years ago
Posted by:
WiseUser
19 years ago
Posted by:
GB1
19 years ago
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
19 years ago
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.
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
19 years ago
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
19 years ago
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]
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
19 years ago
Posted by:
rikx2
19 years ago
Posted by:
MSIMaker
19 years ago
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
19 years ago
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.
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
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
Posted by:
anonymous_9363
16 years ago
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.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
Posted by:
anonymous_9363
16 years ago
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
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.
so that the conversation will remain readable.