开发者

is there any way to use GetProfilesDirectory in jscript?

开发者 https://www.devze.com 2023-02-14 00:29 出处:网络
How can I use GetProfilesDirectory to retrieve c:\\Documents and Settings or c:\\Users (for vista and win7) 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消