edie209
MIS
- Sep 18, 2000
- 106
I am looking at deploying limitlogon. But I have run into a problem.
Just incase LimitLogon is a microsoft product that restricts client logons, so for instance I can set it to one logon only and the client will be automaticaly logged off the 2nd machine logon.
Ok Here is the problem, on PC1 the first logon I get this error
line 70 Char 4 Path not found 800A004C
and on PC2 logging on with the same user account, it recognises that the user account is already logged in and on which machine, I am then asked to click ok to be logged off, but then I get this error
Line 91 Char 6 Path not found 800A004C
and the machine remains logged on.
The script is deployed by use of group policies and I am able to browse to the location of the script. I am at the limit (no pun intended) of my vbs knowledgeand would really apprieciate some help.
*************Here is the full logon script***************
Just incase LimitLogon is a microsoft product that restricts client logons, so for instance I can set it to one logon only and the client will be automaticaly logged off the 2nd machine logon.
Ok Here is the problem, on PC1 the first logon I get this error
line 70 Char 4 Path not found 800A004C
Code:
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
and on PC2 logging on with the same user account, it recognises that the user account is already logged in and on which machine, I am then asked to click ok to be logged off, but then I get this error
Line 91 Char 6 Path not found 800A004C
Code:
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
and the machine remains logged on.
The script is deployed by use of group policies and I am able to browse to the location of the script. I am at the limit (no pun intended) of my vbs knowledgeand would really apprieciate some help.
*************Here is the full logon script***************
Code:
'Begin Constant Declaration
Const Server_Name = "server" 'The server the shared directory will sit on
Const Share_Name = "limitlogon$" ' The share name
Const ForReading = 1
Const ForAppending = 8
Const TIMEOUT = 60
' Begin Variable declaration
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
Dim StrUserName ' Current user
Dim StrStrMachineName
Dim StrStrPathName
Dim StrStrMachineFile
Dim StrStrUserFile
Dim strResponse
Dim textstream
Dim strMachine
Dim strUser
Dim filetxt
'************************* Main Code *************************
'On Error Resume Next
StrUserName = ""
strResponse = ""
' Wait until the user is really logged in...
While StrUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
StrUserName = WSHNetwork.UserName ' Get the user name
Wend
StrMachineName = WshNetwork.ComputerName 'Get the machine Name
StrPathName = "\\" & Server_Name & "\" & Share_Name & "\"
If ((StrUserName = "CyberCafe") OR (StrUserName = "ils")) Then
'Write to log file, do not check for multiple logins.
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
filetxt.writeline(Now() & ", " & StrUserName & ", " & StrMachineName)
filetxt.close
Else
If ObjFSO.FileExists (StrPathName & StrUserName & ".txt") Then 'If the file exists then the user is already logged in.
Set StrUserFile = ObjFSO.CreateTextFile(StrPathName & StrUserName & "1.txt")
StrUserFile.WriteLine StrMachineName
StrUserFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrUserFile.Close
'Read the machine name from username file
Set StrUserFile = ObjFSO.GetFile(StrPathName & StrUserName & ".txt")
set textstream = StrUserFile.openastextstream(1,-2)
strMachine = textstream.readline
if strMachineName = strmachine then 'The user logged on to this computer, but didn't log out properly
Set StrUserFile = ObjFSO.CreateTextFile(StrPathName & StrUserName & ".txt")
StrUserFile.WriteLine StrMachineName
StrUserFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrUserFile.Close
Set StrMachineFile = ObjFSO.CreateTextFile(StrPathName & StrMachineName & ".txt")
strMachineFile.WriteLine strUserName
StrMachineFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrMachineFile.Close
'Write to the log file
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
filetxt.writeline(Now() & ", " & StrUserName & ", " & StrMachineName & ", User didn't log out of this machine properly earlier")
filetxt.close
ObjFSO.DeleteFile (StrPathName & StrUserName & "1.txt")
Else 'The user is logged on at another computer
'Read the username from the machine file
If ObjFSO.FileExists (StrPathName & StrMachine & ".txt") Then
Set StrUserFile = ObjFSO.GetFile(StrPathName & StrMachine & ".txt")
set textstream = StrUserFile.openastextstream(1,-2)
strUser = textstream.readline
Else
strUser = ""
End If
If StrUserName = strUser Then 'The user logged on to the other computer is the same as the user trying to logon to this computer
'Open messagebox informing user that they are already logged on
intReturn = objShell.Popup("You are already logged in at computer " & strMachine & "! You will now be logged off this computer.", 30, "Duplicate Login", Ok_Button)
If intReturn = 1 Then
Wscript.Echo "You clicked the ok button. You will now be logged off"
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
filetxt.writeline(Now() & ", " & StrUserName & ", " & StrMachineName & ", User logged in elsewhere, decided not to login here")
filetxt.close
WshShell.Run "\\server\limitlogon$\logoff.exe /n"
Else
Wscript.Echo "Logon timed out. You will now be logged off"
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
filetxt.writeline(Now() & ", " & StrUserName & ", " & StrMachineName & ", User logged in elsewhere, decided not to login here")
filetxt.close
WshShell.Run "\\server\limitlogon$\logoff.exe /n"
End If
Else
'Another User has logged onto the other computer
Set StrUserFile = ObjFSO.CreateTextFile(StrPathName & StrUserName & ".txt")
StrUserFile.WriteLine StrMachineName
StrUserFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrUserFile.Close
Set StrMachineFile = ObjFSO.CreateTextFile(StrPathName & StrMachineName & ".txt")
strMachineFile.WriteLine strUserName
StrMachineFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrMachineFile.Close
'Write to the log file
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
filetxt.writeline(Now() & ", " & StrUserName & ", " & StrMachineName & ", User didn't log out of other machine correctly")
filetxt.close
ObjFSO.DeleteFile (StrPathName & StrUserName & "1.txt")
End If
End if
Else 'The user is not already logged in, so allow them to login without any questions.
Set StrUserFile = ObjFSO.CreateTextFile(StrPathName & StrUserName & ".txt")
StrUserFile.WriteLine StrMachineName
StrUserFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrUserFile.Close
Set StrMachineFile = ObjFSO.CreateTextFile(StrPathName & StrMachineName & ".txt")
strMachineFile.WriteLine strUserName
StrMachineFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName & " at " & NOW()
StrMachineFile.Close
'Write to the log file
Set filetxt = objFSO.OpenTextFile(strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log", 8, True)
filetxt.writeline(Now() & ", " & StrUserName & ", " & StrMachineName & ", User logged in OK")
filetxt.close
End If
End If