Reading System Variables in Custom Action
Hi all,
I've created a simple MSI with Wise to read the system variables of the %systemroot% and copy a file to it. When I execute the VBS from a command line the script works successfully, but when I embed this as a Custom Action , the %systemroot% variable is returning with a blank value.
What am I missing? Should I be running the CA with special parameters inthe MSI to read the system variables?
Any help appreciated.
thanks.
I've created a simple MSI with Wise to read the system variables of the %systemroot% and copy a file to it. When I execute the VBS from a command line the script works successfully, but when I embed this as a Custom Action , the %systemroot% variable is returning with a blank value.
What am I missing? Should I be running the CA with special parameters inthe MSI to read the system variables?
Any help appreciated.
thanks.
0 Comments
[ + ] Show comments
Answers (15)
Please log in to answer
Posted by:
aogilmor
14 years ago
uh...why are you using vbscript? windows installer can easily read the env. var %systemroot% (on my system, same as %windir%) and just install files to it. Is there any reason to believe that in your environment %systemroot% will ever be something other than the WindowsFolder? If not, just use that. No need for vbscript
Also (from msi.chm)
"If a substring of the form [%environmentvariable] is found, the value of the environment variable is substituted for the substring. "
Also (from msi.chm)
"If a substring of the form [%environmentvariable] is found, the value of the environment variable is substituted for the substring. "
Posted by:
newdude
14 years ago
Hi, thanks for the update. My script backs up some files and shortcuts in the allusersprofile and windir on initialization and works fine when executed in user context. For reasons of "best practice" I am inserting the variables in there but they cannot be read during the execution of the MSI - should the action be run in a particular "phase" (deferred , immediate etc,..) to allow it to be able to read these values? Ill read through the msi.chm a little more.
many thanks.
many thanks.
Posted by:
anonymous_9363
14 years ago
Posted by:
newdude
14 years ago
Posted by:
anonymous_9363
14 years ago
Heard of Google? :-) I'll take pity on you this once, mainly because I have a script open with the declarations in.
As to using the data, presumably your query concerns deferred Custom Actions where you have probably discovered that, by default, you have very limited access to Windows Installer data/properties? Search here and MSDN for details on deferred Custom Actions, specifically for the special CustomActionData property.
Dim objEnvironmentSystem
Dim objEnivironmentUser
Set objWshShell = Wscript.CreateObject("Wscript.Shell")
Set objEnivironmentSystem = WshShell.Environment("SYSTEM")
Set objEnivironmentUser = WshShell.Environment("USER")
You can then use the .Item method to get varaibale content.As to using the data, presumably your query concerns deferred Custom Actions where you have probably discovered that, by default, you have very limited access to Windows Installer data/properties? Search here and MSDN for details on deferred Custom Actions, specifically for the special CustomActionData property.
Posted by:
anonymous_9363
14 years ago
Posted by:
spartacus
14 years ago
Posted by:
newdude
14 years ago
Posted by:
anonymous_9363
14 years ago
shouldn't that be Set objWshShell = CreateObject("Wscript.Shell") if the custom action script is embedded in the MSI ?Top marks, Graham. What can I say? I was still hungry when I posted that.
Ill think again before asking for advice on this forum again!Well, TBH, if you're going to lead with your chin, you have to expect an upper-cut or two. This cr@p is SOOOOOOOOOO easy to find, it's embarrassing. Besides, I was nice! Most people would have got a link to LMGTFY.
Posted by:
newdude
14 years ago
TBH, if you're going to lead with your chin, you have to expect an upper-cut or two. This cr@p is SOOOOOOOOOO easy to find, it's embarrassing. Besides, I was nice! Most people would have got a link to LMGTFY.
Its confirmed , you're a typical arrogant techie c0ck! I have skills in other others but do not feel the need to berate others when questions are asked to me about my specialist subjects. Maybe it makes you feel big, maybe you're just a c0ck, maybe this in the *ONLY* skill you have but please do me a favour if I do ask any more "SILLY" questions then please control yourself and refrain from "assisting" me - id rather soldier on on my own.
Posted by:
anonymous_9363
14 years ago
Completely wrong. It simply gets very tiresome dealing with people who seem unable to type "VBScript +environment +variable" into Google.
BTW, if your embedded script is running in the deferred sequence, it will have access to a very limited set of properties. Search AppDeploy for 'CustomActionData' for details on how to pass property values to the deferred sequence. There: how was that?
BTW, if your embedded script is running in the deferred sequence, it will have access to a very limited set of properties. Search AppDeploy for 'CustomActionData' for details on how to pass property values to the deferred sequence. There: how was that?
Posted by:
newdude
14 years ago
There: how was that?
Much better thanks BUT if you do google "VBScript +environment +variable" it does not answer the question. I know how to use a system variable on a VBScript, the issue was using that when this method during a CA from with an MSI returned a blank (or null) value.
As discussed earlier on in the thread the issue was found to be the use of WSCRIPT to which now i better educated on and was proving difficult for me to find.
Thanks.
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.