GuestShell.GetEnvironmentVariables()["APPDATA"] for VM with Windows XP is not presented in the dictionary

Feb 3, 2011 at 6:55 AM
Edited Feb 3, 2011 at 12:32 PM

Hi,

When I use command GuestShell.GetEnvironmentVariables()["APPDATA"] for VM with Windows XP 64 bit - I get an exception "key is not presented in the dictionary"

But if I manually go to VM and execute "set" in cmd there is such variable.

I need an advice )

For VM with Win7 it looks like it works fine.

I suspect that RUnCommandInGuest in WinXP is somehow run from other user, could it be so?

Coordinator
Feb 3, 2011 at 12:09 PM

There's a lot of stuff going on under the hood with regards to sessions and logons that define what kind of variables you inherit. I would dump the entire environment with a RunProgramInGuest (just call set > somefile) and would diff the two. This should point out to what that other logon that's missing APPDATA is.

Feb 3, 2011 at 12:46 PM

Well, here is a result from RunCommandInGuest("set") for WinXP64:

ALLUSERSPROFILE=C:\Documents and Settings\All Users
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
COMPUTERNAME=WINXP64-4DC6R
ComSpec=C:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\
LIB=C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Subversion\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=EM64T Family 6 Model 30 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=1e05
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
PROMPT=$P$G
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
USERPROFILE=C:\Documents and Settings\Administrator
VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
VS71COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Common7\Tools\
VS80COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\
VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\
windir=C:\WINDOWS

Coordinator
Feb 4, 2011 at 4:16 AM

Clearly APPDATA is not there. It's got to be something to do with terminal services, but I think you're on your own here. Post if you find something.

Feb 4, 2011 at 11:24 AM

I found a thread about the same problem.

http://communities.vmware.com/thread/192580?start=15&tstart=0

Guys are using powershell and set appdata env var (if empty) themselves.

Next problem is that I am not using powershell or Windows support tools and thus it is not easy to set global env var.

I will keep you informed.

Coordinator
Feb 4, 2011 at 12:50 PM

If it's empty, it's empty. If you need it on the client app, just set it to something if the remote returned that it doesn't exist?