【问题标题】:is there any way to use GetProfilesDirectory in jscript?有没有办法在 javascript 中使用 GetProfiles 目录?
【发布时间】:2011-03-01 18:51:32
【问题描述】:

如何使用 GetProfilesDirectory 在 Jscript 中检索 c:\Documents and Settings 或 c:\Users(适用于 vista 和 win7)?

或者获取用户配置文件路径(不是当前用户)的任何替代方法,但对于非 AD 场景中的任何给定用户。

【问题讨论】:

标签: javascript user-profile


【解决方案1】:

您不能在 JScript 中使用 GetProfilesDirectory 函数,因为 Windows Script Host 不支持调用 Windows API 函数。但是,您可以从HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ProfilesDirectory 注册表值获取配置文件目录路径。这是一个例子:

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);

或者获取用户配置文件路径(不是当前用户)的任何替代方法,但对于非 AD 场景中的任何给定用户。

上面提到的ProfileList注册表键有对应不同用户的子键。用户的配置文件路径由相应子项的ProfileImagePath 值指定。

【讨论】:

    猜你喜欢
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多