ビデオヘルプ

Get Environment Variable in Wise Embedded VB

作成: 20 Dec 2012 • 更新: 21 Dec 2012 | コメント数: 4
この問題は解決されました。 ソリューションを参照してください。

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

タグでディスカッションを検索:

コメント コメント数: 4最新のコメントを表示

AngelD の写真

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
ソリューション
piyushnasa の写真

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 の写真

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.