title: returning variable from functions vbs
body: <p>I've been banging my head against the wall for a couple of days now and can't work out whats wrong with my code. I'm sure its fairly simple but just can't see it. I'm trying to return a list of users who logged on to a machine and the time. Due to the environment being locked down I've had to read the registry.</p>
  
  <pre><code>Option Explicit
  Const HKEY_LOCAL_MACHINE = &amp;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:\\" &amp; _ 
      strComputer &amp; "\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 &amp; "\" &amp; objSubkey
      objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
      'strUser = Replace(strValue,"C:\Documents and Settings\","")
      'Set colMatches = objRegEx.Execute(strUser)
      'If colMatches.Count &lt; 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\" &amp; 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) &lt;&gt; "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
  </code></pre>
  
  <p>Runnning the above returns</p>
  
  <pre><code>profile.vbs(36, 5) Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment: 'ProfileTime'
  </code></pre>
  
  <p>Bit lost a the moment</p>