Differences how environment variables are resolved when using RUP

by Mitch Tulloch [Published on 11 April 2012 / Last Updated on 11 April 2012]

This tip explains a difference between Windows 7 and Windows XP in how environment variables are resolved when logging on using a roaming user profile.

There is a difference between Windows 7 (or Windows Vista) and Windows XP in how environment variables are resolved when logging on using a roaming user profile.  This can be important if you use Group Policy Preferences (GPP) to define custom environment variables and then use these variables, for example as part of the path for roaming user profiles.

For example, say you configure the profile path for a roaming user as \\servername\profiles\%username%\%PCTYPE% and then use GPP to specify that the system environment variable %PCTYPE% should be equal to "XP" if the computer is running Windows XP and "W7" if the computer is running Windows 7.  If you do this, a user who logs onto a Windows XP computer for the first time will have \\servername\profiles\username\XP used when their roaming profile is created, but a user who logs onto a Windows 7 computer for the first time will have \\servername\profiles\username\%PCTYPE%.v2 used when their roaming profile is created instead of the expected \\servername\profiles\username\W7.v2.  But if the user who logs onto a Windows 7 computer for the first time reboots their computer before they first log onto it, then they will have \\servername\profiles\username\W7v2 used when their roaming profile is created.  In other words, the environment variable for Windows 7 that has been specified using GPP doesn't "take" unless the computer is rebooted before the user logs on for the first time. The reason for this difference is because Windows 7 (and Windows Vista) have a new service called the User Profile Service that relies on the environment variables of the svchost process, which loads before GPP preferences is applied. 

Mitch Tulloch is a seven-time recipient of the Microsoft Most Valuable Professional (MVP) award and widely recognized expert on Windows administration, deployment and virtualization. For more tips by Mitch you can follow him on Twitter or friend him on Facebook.

 

Featured Links