I need a way to expand environment variable on a remote machine.
Suppose I have a path to a folder %appdata%\\MyApp\\Plugins or %ProgramFiles%\\My
Environment variables are the amalgamation of 'puter-wide and per-user settings. A running process may modify its environment and when it spawns another process, that process inherits the environment of the process that created it.
Unless you have access to a process running on the remote machine (or can start one), there's no such thing as an 'environment': the context for it simply doesn't exist. The environment of a particular process is a function of all of the following:
That being said, Windows keeps its environment variable settings in the registry:
HKEY_CURRENT_USER\EnvironmentHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\EnvironmentIf you have appropriate access to the remote machine's registry, you should be able to fish out what you need.
Note that environment variables may be defined in terms of other environment variables: I believe you'll likely to take care of the proper expansion yourself.