GuestEnvironmentVariable not Workering

Dec 28, 2011 at 4:51 PM

I have everything working but the GuestEnvironmentVariable. Both entries return blank when in fact they are not emty on the guest vm.
                        try
                        {
                            virtualMachine.WaitForToolsInGuest();
                            virtualMachine.LoginInGuest(vmGuestUser, pgtCrypto.DecryptStringAES(vmGuestPS, SecretKey), 8, 15);
                            if (ProgramExec.Contains("[%SYS32%]"))
                            {
                                var test = virtualMachine.GuestEnvironmentVariables["windir"];
                                var env = virtualMachine.GuestEnvironmentVariables["USERNAME"];
                                ProgramExec = ProgramExec.Replace("[%SYS32%]", "");
                            }
                            var err = virtualMachine.RunProgramInGuest(ProgramExec, ProgramCmdArgs, 2, 600);
                            virtualMachine.LogoutFromGuest(30);
                            vmReturn = err.ExitCode;
                        }
Is there something I'm doing wrong?
-Mike

Developer
Dec 28, 2011 at 7:00 PM

From http://communities.vmware.com/message/1166742:

Shell guestShell = new Shell(poweredVirtualMachine);

Dictionary<string, string> guestEnvironmentVariables = guestShell.GetEnvironmentVariables();

Console.WriteLine(guestEnvironmentVariables);

Dec 28, 2011 at 7:27 PM

Thanks, that worked.

-Mike