In Vista, I am trying to get "Local AppData" path for an user account (other than current user) on a local machine but facing some issue. can anyone pls help me what is wrong with the below code.
var HKU = 0x80000003;
var username = "xyz";
//Loading registry hive of user xyz
var WshShell = new ActiveXObject("WScript.Shell");
var LoadHiveCmd = "REG LOAD " + "HKU" + "\\" + username + " \"" + "c:\\users\\xyz\\NTUSER.DAT" + "\"";
var oExec = WshShell.Exec(strLoadHiveCmd);
var oReg = GetObject("WinMgmts:/root/default:StdRegProv");
var profileRegPath = username + "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
var method, inparams, outparams;
method = oReg.Methods_.Item("GetExpandedStringValue");
inparams = method.InParameters.SpawnInstance_();
inparams.hDefKey = HKU;
inparams.sSubKeyName = profileRegPath ;
inparams.sValueName = "Local AppData";
outparams = oReg.ExecMethod_(method.Name, inparams);
var appDataPath= outparams.sValue;
Here the appDataPath value in the registry is %USERPROFILE%\AppData\Local
But I am getting a value C:\Windows\system32\config\systemprofile\AppData\Local
I dont understand from where the value c:\windows\system32\config\systemprofile
is coming and how it replaced %USERPROFILE%
value.