Screencasts - Hilfsvideos

Get Environment Variable in Wise Embedded VB

Created: 20 Dez. 2012 • Aktualisiert: 21 Dez. 2012 | 4 Kommentare
Dieses Problem wurde gelöst. Siehe Lösung.


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

Kategorien für Diskussion:

Kommentare KommentareZum neuesten Kommentar

das Bild der AngelDs

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
das Bild der piyushnasas

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.

Piyush Nasa Altiris Certified Professional (ACP)

das Bild der EdTs

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.