我已經撞了我的頭撞牆了幾天,現在無法解決我的代碼有什麼問題。我相信它非常簡單,但看不到它。我試圖返回登錄到機器的用戶列表和時間。由於環境被鎖定,我必須閱讀註冊表。從函數返回變量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