Okay I'll have to apologize as I picked a Registry key that did not have the proper characteristics of what I was attempting to show.


Basically I wanted to demonstrate that you could not use the
ExpandEnvironmentVars to obtain the data from a remote system.
If it was the same version OS and all default installation directories you could "assume" but that still would not be the best action to take.
You should code something that would give the correct results regardless of the installation directory.

Here is an example script to demonstrate.




;Script should be run from a Windows XP system. 

If Not @LogonMode
Break On
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')

;Declare our vars
Dim $RegSubKey, $RegValue, $RemoteRead, $LocalRead, $sComputer
Dim $ExpandRemoteRead, $ExpandLocalRead

;Remote System must be Windows 2000 to demonstrate
$sComputer='name of a remote windows 2000 system goes here'

;Remove any leading or trailing back slashes from the computer name then add them back
;in case someone adds or puts the wrong amount of back slashes
$sComputer=IIf(Not $sComputer,'','\\'+Join(Split($sComputer,'\'),'',3)+'\')

;Define our main key
$RegSubKey='HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion'

;Define our value to lookup
$RegValue='MediaPathUnexpanded'

;Read the Registry without expanding
$RemoteRead = ReadValue($sComputer+$RegSubKey,$RegValue)
$LocalRead = ReadValue($RegSubKey,$RegValue)

;Read the Registry expanding the environment vars
$ExpandRemoteRead = ExpandEnvironmentVars(ReadValue($sComputer+$RegSubKey,$RegValue))
$ExpandLocalRead = ExpandEnvironmentVars(ReadValue($RegSubKey,$RegValue))

;Display our NO EXPAND results
'Local No Expand: ' + $LocalRead ?
'Remote No Expand: ' + $RemoteRead ??

;Display our EXPAND results
'Local Expand: ' + $ExpandLocalRead ?
'Remote Expand: ' + $ExpandRemoteRead ?

;In this case you should notice that all output is the same
;however the path on a Windows 2000 system should be something like
;C:\WINNT and not C:\WINDOWS