/build/static/layout/Breadcrumb_cap_w.png

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.

0 Comments   [ + ] Show comments

Answers (15)

Posted by: aogilmor 13 years ago
9th Degree Black Belt
0
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. "
Posted by: newdude 13 years ago
Senior Yellow Belt
0
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.
Posted by: anonymous_9363 13 years ago
Red Belt
0
I'd place a sizable wager that your script uses the 'WScript' directive when creating objects? I shan't repeat myself: search AppDeploy for 'directive'.
Posted by: newdude 13 years ago
Senior Yellow Belt
0
ok.answer found.

many thanks.
Posted by: anonymous_9363 13 years ago
Red Belt
0
Well, give us a clue! Was it the 'WScript' directive?
Posted by: newdude 13 years ago
Senior Yellow Belt
0
The issue was indeed the Wscript object which begs me to ask the question again, when I use a VBS in a custom action is there any way to use a SYSTEM or USER variables present on the target machine in my scripts?

Many thanks.
Posted by: anonymous_9363 13 years ago
Red Belt
0
Heard of Google? :-) I'll take pity on you this once, mainly because I have a script open with the declarations in.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: timmsie 13 years ago
Fourth Degree Brown Belt
0
tut tut tut, not closing your code tag correctly!
Posted by: anonymous_9363 13 years ago
Red Belt
0
[shame-faced]Tut, tut indeed...[/shame-faced]I'm hungry. That's my excuse.
Posted by: spartacus 13 years ago
Black Belt
0
ORIGINAL: VBScab

[font="Courier New"]Set objWshShell = Wscript.CreateObject("Wscript.Shell")


shouldn't that be Set objWshShell = CreateObject("Wscript.Shell") if the custom action script is embedded in the MSI ?

Spartacus
Posted by: newdude 13 years ago
Senior Yellow Belt
0
ORIGINAL: VBScab

Heard of Google? :-) I'll take pity on you this once



Thanks for the patronising response (I was warned about you )....Ill think again before asking for advice on this forum again!
Posted by: anonymous_9363 13 years ago
Red Belt
0
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 13 years ago
Senior Yellow Belt
0
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 13 years ago
Red Belt
0
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?
Posted by: newdude 13 years ago
Senior Yellow Belt
0
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.
 
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