Video Screencast Help
Protect Your POS Environment Against Retail Data Breaches. Learn More.

Get Environment Variable in Wise Embedded VB

Created: 20 Dec 2012 • Updated: 21 Dec 2012 | 4 comments
This issue has been solved. See solution.

Hi,

I have CA - call Vb script from embedded code- I need to copy a file from %Locam% to %Locaset% in this CA. how can I use Environment Variable in the Vbscript to copy the file. I think I may need to use "Get Environment Variable" but how ?

Thank you for your help

Comments 4 CommentsJump to latest comment

AngelD's picture

Using VBScript to resolve string with env. variables you could use:

 

Source = "%Locam%\file.ext"
Dest = "%Locaset%\file.ext"
<CopyFile method> ExpandEnvironmentStrings(Source), ExpandEnvironmentStrings(Dest)
 
Function ExpandEnvironmentStrings(ByVal value)
Dim oWshShell
Set oWshShell = CreateObject("WScript.Shell")
 
ExpandEnvironmentStrings = oWshShell.ExpandEnvironmentStrings(value)
Set oWshShell = Nothing
End Function

 

SOLUTION
piyushnasa's picture

If you want you can also set environment variable to a property in MSI with SetProperty CA and setting its value to [%Locam]

then you can use this property in your VBScript CA. If this VBScript CA is running in Immediate mode, it should not be problem and you can access the property directly. However if it is running in deferred execution mode then you need to pass this property to the CA. 

Follow this link for how to do this.

https://www-secure.symantec.com/connect/blogs/prop...

Piyush Nasa Altiris Certified Professional (ACP)

http://msiworld.blogspot.com/

EdT's picture

Are the variables %Locam% and %Locaset% pointing to local or network resources?

I assume local, but if either of them are network based, then you may need to run your CA in user context in order to have access to the network.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.