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

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

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. "
Answered 12/06/2010 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
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.
Answered 12/06/2010 by: newdude
Senior Yellow Belt

Please log in to comment
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'.
Answered 12/07/2010 by: VBScab
Red Belt

Please log in to comment
0
ok.answer found.

many thanks.
Answered 12/07/2010 by: newdude
Senior Yellow Belt

Please log in to comment
0
Well, give us a clue! Was it the 'WScript' directive?
Answered 12/07/2010 by: VBScab
Red Belt

Please log in to comment
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.
Answered 12/08/2010 by: newdude
Senior Yellow Belt

Please log in to comment
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.
Answered 12/08/2010 by: VBScab
Red Belt

Please log in to comment
0
tut tut tut, not closing your code tag correctly!
Answered 12/08/2010 by: timmsie
Fourth Degree Brown Belt

Please log in to comment
0
[shame-faced]Tut, tut indeed...[/shame-faced]I'm hungry. That's my excuse.
Answered 12/08/2010 by: VBScab
Red Belt

Please log in to comment
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
Answered 12/08/2010 by: spartacus
Black Belt

Please log in to comment
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!
Answered 12/08/2010 by: newdude
Senior Yellow Belt

Please log in to comment
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.
Answered 12/08/2010 by: VBScab
Red Belt

Please log in to comment
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.
Answered 12/09/2010 by: newdude
Senior Yellow Belt

Please log in to comment
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?
Answered 12/09/2010 by: VBScab
Red Belt

Please log in to comment
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.
Answered 12/09/2010 by: newdude
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity