几天来,我一直把头撞在墙上,无法弄清楚我的代码有什么问题。我敢肯定它相当简单,但就是看不到它。我正在尝试返回登录到机器的用户列表和时间。由于环境被锁定,我不得不阅读注册表。
Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Dim oNet, WMI, strComputer, tz, os, objRegistry, strKeyPath, strSubPath, strValueName, strValue, arrSubkeys, objSubKey, strSID, strUser, objReg, lngHighValue, lngLowValue, Return, strReturn, NanoSecs, DT
Set oNet = CreateObject("WScript.Network")
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
strComputer = oNet.Computername
tz = 0
For Each os In GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
tz = os.CurrentTimeZone
Exit For
Next
'Set objRegEx = CreateObject("VBScript.RegExp")
'objRegEx.Global = True
'objRegEx.IgnoreCase = True
'objRegEx.Pattern = "default|all users|administrator|localservice|networkservice|ueit-admn-[0-9]|3rd-admn-[0-9]|systemprofile"
Set objRegistry=GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
strValueName = "ProfileImagePath"
strSID = objSubKey
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
'strUser = Replace(strValue,"C:\Documents and Settings\","")
'Set colMatches = objRegEx.Execute(strUser)
'If colMatches.Count < 1 Then
Call ProfileTime(strSID)
'WScript.echo ProfileTime
'End If
Next
Function ProfileTime(strSID)
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv" )
strKeyPath = "SOFTWARE\MICROSOFT\Windows NT\CurrentVersion\ProfileList\" & strSID
strValueName = "ProfileLoadTimeHigh"
Return = objReg.GetDWORDValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,lngHighValue)
strValueName = "ProfileLoadTimeLow"
Return = objReg.GetDWORDValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,lngLowValue)
If typename(lngHighValue) <> "Null" then
NanoSecs = (lngHighValue * 2 ^ 32 + lngLowValue)
'' /* Returns time in Workstation Timezone */
DT = #1/1/1601# + (NanoSecs / 600000000 / 1440) + (tz / 1440)
Set ProfileTime = CDate(DT)
End If
End Function
运行上述返回
profile.vbs(36, 5) Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment: 'ProfileTime'
有点失去了那一刻