is there any way to use GetProfilesDirectory in jscript?
How can I use GetProfilesDirectory to retrieve c:\Documents and Settings or c:\Users (for vista and win7) in Jscript?
Or else any alternative way to get the user profile path (not of the c开发者_开发百科urrent user) but for any given user in a Non-AD scenario.
You can't use the GetProfilesDirectory
function in JScript, because Windows Script Host doesn't support calling Windows API functions. However, you can get the profiles directory path from the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ProfilesDirectory
registry value. Here's an example:
var oShell = new ActiveXObject("WScript.Shell");
var strProfilesDir = oShell.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\ProfilesDirectory");
strProfilesDir = oShell.ExpandEnvironmentStrings(strProfilesDir);
WScript.Echo(strProfilesDir);
Or else any alternative way to get the user profile path (not of the current user) but for any given user in a Non-AD scenario.
The abovementioned ProfileList
registry key has subkeys corresponding to different users. The user's profile path is specified by the ProfileImagePath
value of the appropriate subkey.
精彩评论