使用 WSH,可以輕松地使用 Windows 管理規(guī)范 (WMI)。下面的腳本將演示如何使用 WSH 和 WMI 來通過 ADSI 檢索用戶的登錄時間。
注意 有關(guān) WMI 的詳細信息,請參閱 WMI SDK,網(wǎng)址為 (http://www.microsoft.com/china/msdn/)。
// JScript。 LoginProfiles = GetObject("winmgmts:").InstancesOf ("Win32_NetworkLoginProfile"); for(e = new Enumerator(LoginProfiles) ; !e.atEnd() ; e.moveNext()) { Profile = e.item(); WScript.Echo(Profile.Name); WScript.Echo(Profile.LastLogon); } ' VBScript。 Set LoginProfiles = GetObject("winmgmts:").InstancesOf ("Win32_NetworkLoginProfile") for each Profile in LoginProfiles WScript.Echo Profile.Name WScript.Echo Profile.LastLogon next