2011-03-01 2 views
1

Jscript에서 GetProfilesDirectory를 사용하여 c : \ Documents and Settings 또는 c : \ Users (Vista 및 win7 용)를 검색하는 방법은 무엇입니까?jscript에서 GetProfilesDirectory를 사용할 수있는 방법은 무엇입니까?

또는 다른 방법으로 현재 사용자가 아닌 사용자 프로필 경로를 가져올 수 있지만 비 AD 시나리오의 특정 사용자는 사용할 수 없습니다.

+1

관련 항목 : [Windows의 "C : \ Documents and Settings"폴더 또는 C : \ Users 폴더를 나타내는 환경 변수가 있습니까?] (http://stackoverflow.com/q/4504016/113116) – Helen

답변

1

Windows 스크립트 호스트가 Windows API 함수 호출을 지원하지 않기 때문에 GetProfilesDirectory 함수를 JScript에서 사용할 수 없습니다. 그러나 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ProfilesDirectory 레지스트리 값에서 profiles 디렉터리 경로를 가져올 수 있습니다. 다음 예는 다음과 같습니다

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에 의해 지정됩니다.

관련 문제