Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim vaEndSessionData(5)
- 'Get date and time.
- vaEndSessionData(0)=Date
- vaEndSessionData(1)=Time
- strTimeNow = Date & " " & Time
- 'Get time of logon and calculate difference
- Set objTemp = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2)
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.OpenTextFile(objTemp & "\Logon_Time.tmp", 1)
- strTimeThen = objFile.ReadLine
- objFile.Close
- intSecsDifferent=DateDiff("s", strTimeThen, strTimeNow)
- vaEndSessionData(2)=intSecsDifferent
- Function SplitSec(pNumSec)
- Dim d, h, m, s
- Dim h1, m1
- d = int(pNumSec/86400)
- h1 = pNumSec - (d * 86400)
- h = int(h1/3600)
- m1 = h1 - (h * 3600)
- m = int(m1/60)
- s = m1 - (m * 60)
- SplitSec = cStr(d) & "d " & cStr(h) & "h " & cStr(m) & "m " & cStr(s) & "s"
- End Function
- vaEndSessionData(3)=SplitSec(intSecsDifferent)
- 'Update some local computer information
- strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''"
- Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
- Set colItems = objWMIService.ExecQuery( strQuery, "WQL", 48 )
- 'Get some useful local computer information
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- Set colSettings = objWMIService.ExecQuery _
- ("Select * from Win32_OperatingSystem")
- For Each objOperatingSystem in colSettings
- vaEndSessionData(4)=objOperatingSystem.FreePhysicalMemory
- Next
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
- For Each objItem in colItems
- vaEndSessionData(5)=objItem.LoadPercentage
- Next
- 'write out to file and clean up
- vJoinedArray=(join(vaEndSessionData,","))
- Set objTemp = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2)
- Set objFSOr = CreateObject("Scripting.FileSystemObject")
- Set objFiled = objFSOr.OpenTextFile(objTemp & ".\Session_Info.log", 1)
- strLogonInfo = objFiled.ReadLine
- objFiled.Close
- 'Wscript.Echo strLogonInfo & "," & vJoinedArray
- strSessionInfo = strLogonInfo & "," & vJoinedArray
- Dim objFileSystem, objOutputFile
- Dim strOutputFile
- strOutputFile = "\\server.domain\share$\logfile.log"
- Set objFileSystem = CreateObject("Scripting.fileSystemObject")
- Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, 8)
- objOutputFile.WriteLine (strSessionInfo)
- objOutputFile.Close
- Set objFileSystem = Nothing
- Set objTemp = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2)
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- objFSO.DeleteFile(objTemp & "\Session_Info.log")
- objFSO.DeleteFile(objTemp & "\Logon_Time.tmp")
- WScript.Quit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement