Option Explicit Dim ObjFSO, wshShell, wshNetwork, objLDAP, objLDAPUser Set objFSO=CreateObject("Scripting.FileSystemObject") Set wshShell = CreateObject("wscript.Shell") Set wshNetwork = wscript.CreateObject( "wscript.Network" ) Set objLDAP = CreateObject("ADSystemInfo") Set objLDAPUser = GetObject("LDAP://" & objLDAP.UserName) '''Declare constants Const saveRootComputer = "\\SERVER\SHARE$\computer\" Const saveRootUsername = "\\SERVER\SHARE$\user\" Const logFileExtension = ".log" ''' '''sets the computername Dim strComputerName strComputerName = lcase(wshNetwork.ComputerName) ''' ''' Sets the Username Dim strUsername strUsername = lcase(objLDAPUser.sAMAccountName) ''' ''' Sets the FullName Dim strFullName strFullName = LCase(objLDAPUser.DisplayName) ''' ''' Sets the current Date Dim strDateNow strDateNow = Date ''' ''' Sets the Time Dim strTimeNow strTimeNow = Time ''' '''FOR DEBUG ONLY - Comment out once finished 'strUsername = "09testt" 'strComputerName = "TEST-1" ''' ''' Gets the User Type Dim strUsernameType strUsernameType = Left(strUsername,2) ''' ''' Set Save Path based on user model or quit if not student or staff login (st- or 0x- or 1x-) Dim savePathUser If strUsernameType = "st" Then savePathUser = saveRootUsername & "staff\" ElseIf InStr(1, strUsernameType, "2") = 1 Or InStr(1, strUsernameType, "1") = 1 Then savePathUser = saveRootUsername & "intake20" & strUsernameType & "\" Else savePathUser = saveRootUsername End If ''' ''' Do Folder Check - does it exist? If Not (objFSO.FolderExists(savePathUser)) Then objFSO.CreateFolder SavePathUser End If ''' ''' Populate User Save Path Dim fullUserSavePath fullUserSavePath = savePathUser & strUsername & logFileExtension ''' ''' Check User Save File Exists If Not ObjFSO.FileExists(fullUserSavePath) Then ObjFSO.CreateTextFile(fullUserSavePath) End If ''' ''' Populate Computer Save path Dim fullComputerSavePath fullComputerSavePath = saveRootComputer & strComputerName & logFileExtension ''' Check Computer file exists If Not ObjFSO.FileExists(fullComputerSavePath) Then ObjFSO.CreateTextFile(fullComputerSavePath) End If ''' ''' Computer line insert Dim strComputerLineInsert strComputerLineInsert = strDateNow & "," & strTimeNow & "," & strUsername & "," & strFullName & ", logon" ''' ''' User line Insert Dim strUserLineInsert strUserLineInsert = strDateNow & "," & strTimeNow & "," & strComputerName & "," & strFullName & ", logon" ''' ''' Insert line into computerfile Dim c Set c = ObjFSO.OpenTextFile(fullComputerSavePath, 8, False) c.WriteLine strComputerLineInsert c.Close ''' ''' Insert line into computerfile Dim u Set u = ObjFSO.OpenTextFile(fullUserSavePath, 8, False) u.WriteLine strUserLineInsert u.Close ''' 'WScript.echo strComputerName 'WScript.Echo strUsername 'WScript.Echo strUsernameType 'WScript.Echo savePathUser 'WScript.Echo fullUserSavePath 'WScript.Echo fullComputerSavePath 'WScript.Echo strComputerLineInsert 'WScript.Echo strUserLineInsert