我已经撞了我的头撞墙了几天,现在无法解决我的代码有什么问题。我相信它非常简单,但看不到它。我试图返回登录到机器的用户列表和时间。由于环境被锁定,我必须阅读注册表。从函数返回变量vbs
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'
位失去了的那一刻
您上面的代码没有36行。请发布您的整个脚本,并指出哪一个是行号36. – Nilpo 2012-04-05 12:45:40