WSH および WMI (Windows Management Instrumentation)
WSH を使用すると、WMI (Windows Management Instrumentation) を簡単に使用できます。次のスクリプトは、WSH と WMI を使って特定ユーザーのログオン時刻を ADSI 経由で取得する例を示しています。
メモ WMI の詳細については、https://msdn.microsoft.com の「WMI SDK」を参照してください。
// 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