Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

800A004C path not found

Status
Not open for further replies.

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

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
 
CaSE matters here. Try this.

At line 35: StrUserName = lcase(WSHNetwork.UserName)
at line 41: If ((StrUserName = "cybercafe") OR (StrUserName = "ils")) Then

I troubleshoot issues like this by echoing out what is going into the IF then echo what has actually made it into the IF.
Example
Code:
wscript.echo that
If this=that then
  wscript.echo "made it into if"
Else
  wscript.echo "made it into else"
End if
I hope this helps.
 
If the pathname is wrong try sending it to a msgbox and double check that the filename that you are setting is correct msgbox strpathname & "logs\" & formatdatetime(Now(),vblongdate) & ".log"
Sometimes I find that there is a slash I left out.
 
Thanks for the replies I have tried the CaSe issue with no luck, as to the code you suggested where should i put that?
 
What lines are you getting errors on?

Does the Const Share_Name = "limitlogon$" have permissions for these users to write to the directory?

Would you try to change the limitlogon$ share to a non-hidden share with access for Everyone to Modify the files to see if that works?






 
Hi thanks for the suggestions

I have now made the share a non hidden share and checked and rechecked the permissions the error has now changed to line 121 Char 3 error 800A004C path not found

Set StrUserFile = ObjFSO.CreateTextFile(StrPathName & StrUserName & ".txt")


 
Did you try echoing out: StrPathName & StrUserName & ".txt" to see if it is the correct path?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top