pk24573
asked on
VB SCRIPT ERRORS "Input past end of file" and "Permission Denied"
Hello all,
Im running this script to monitor logon/logoff activity in my network.
The script runs fine (it documents everything in my log file.
However, i get 2 errors on my clients.
error : Permission denied (800A0046)
line 121
and
error :Input past end of file (800a003e)
line 118
i have given full access to all clients to the log file.
Any help will be much appreciated.
Thanks.
Im running this script to monitor logon/logoff activity in my network.
The script runs fine (it documents everything in my log file.
However, i get 2 errors on my clients.
error : Permission denied (800A0046)
line 121
and
error :Input past end of file (800a003e)
line 118
i have given full access to all clients to the log file.
Any help will be much appreciated.
Thanks.
Option Explicit
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns
Dim intConstants, intTimeout, strTitle, intCount, blnLog
Dim strUserName, strComputerName, strIP, strShare, strLogFile
strShare = "\\Filesrv\Log_share"
strLogFile = "logon.log"
intTimeout = 20
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Wscript.Shell")
strUserName = objNetwork.UserName
strComputerName = objNetwork.ComputerName
strIP = Join(GetIPAddresses())
' Log date/time, user name, computer name, and IP address.
If (objFSO.FolderExists(strShare) = True) Then
On Error Resume Next
Set objLogFile = objFSO.OpenTextFile(strShare & "\" _
& strLogFile, 8, True, 0)
If (Err.Number = 0) Then
' Make three attempts to write to log file.
intCount = 1
blnLog = False
Do Until intCount = 3
objLogFile.WriteLine "Logon ; " & Now & " ; " _
& strComputerName & " ; " & strUserName & " ; " & strIP
If (Err.Number = 0) Then
intCount = 3
blnLog = True
Else
Err.Clear
intCount = intCount + 1
If (Wscript.Version > 5) Then
Wscript.Sleep 200
End If
End If
Loop
On Error GoTo 0
If (blnLog = False) Then
strTitle = "Logon Error"
strText = "Log cannot be written."
strText = strText & vbCrlf _
& "Another process may have log file open."
intConstants = vbOKOnly + vbExclamation
intAns = objShell.Popup(strText, intTimeout, strTitle, _
intConstants)
End If
objLogFile.Close
Else
On Error GoTo 0
strTitle = "Logon Error"
strText = "Log cannot be written."
strText = strText & vbCrLf & "User may not have permissions,"
strText = strText & vbCrLf & "or log folder may not be shared."
intConstants = vbOKOnly + vbExclamation
intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants)
End If
Set objLogFile = Nothing
End If
' Clean up and exit.
Set objFSO = Nothing
Set objNetwork = Nothing
Set objShell = Nothing
Wscript.Quit
Function GetIPAddresses()
' Based on a Michael Harris script, modified by Torgeir Bakken
'
' Returns array of IP Addresses as output
' by IPConfig or WinIPCfg...
'
' Win98/WinNT have IPConfig (Win95 doesn't)
' Win98/Win95 have WinIPCfg (WinNt doesn't)
'
' Note: The PPP Adapter (Dial Up Adapter) is
' excluded if not connected (IP address will be 0.0.0.0)
' and included if it is connected.
Dim objShell, objFSO, objEnv, strWorkFile, objFile
Dim arrData, intIndex, n, arrIPAddresses, arrParts
Set objShell = CreateObject("wscript.shell")
Set objFSO = CreateObject("scripting.filesystemobject")
Set objEnv = objShell.Environment("PROCESS")
If (objEnv("OS") = "Windows_NT") Then
strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName
objShell.Run "%comspec% /c IPConfig >" & Chr(34) _
& strWorkFile & Chr(34), 0, True
Else
' WinIPCfg in batch mode sends output to
' filename WinIPCfg.out
strWorkFile = "WinIPCfg.out"
objShell.Run "WinIPCfg /batch", 0, True
End If
Set objShell = Nothing
Set objFile = objFSO.OpenTextFile(strWorkFile)
arrData = Split(objFile. ReadAll, vbCrLf)
objFile.Close
Set objFile = Nothing
objFSO.DeleteFile strWorkFile
Set objFSO = Nothing
arrIPAddresses = Array()
intIndex = -1
For n = 0 To UBound(arrData)
If (InStr(arrData(n), "IP Address") > 0) Then
arrParts = Split(arrData(n), ":")
If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then
intIndex = intIndex + 1
ReDim Preserve arrIPAddresses(intIndex)
arrIPAddresses(intIndex)= Trim(CStr(arrParts(1)))
End If
End If
It could even be when trying to create the temp file that is created in the IP function
You can take the function out and paste in anew temporary script and call it like you do in the main part of your script.
then run it on the faulty machine with some Echo's to try ascertain where the problem lies.
Krystian
You can take the function out and paste in anew temporary script and call it like you do in the main part of your script.
then run it on the faulty machine with some Echo's to try ascertain where the problem lies.
Krystian
ASKER
i dont know anything about scripting. i.e echo ip function is greek to me...
the script works fine, it just produces these errors when a user logs in to the pc
the script works fine, it just produces these errors when a user logs in to the pc
ASKER
and one more major thing,
just reviewed the script as posted here, its line 103 and line 106
just reviewed the script as posted here, its line 103 and line 106
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Re-reading your post agan - does the error occur everytime on every client??
Again, i can write a more effieicent IPAddress Function for you that will resolve this if you wish (i'll make it so you need do nothing if your uncomfortable with writing scripts)
Krystian
Again, i can write a more effieicent IPAddress Function for you that will resolve this if you wish (i'll make it so you need do nothing if your uncomfortable with writing scripts)
Krystian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hello,
sorry about the delay, the script is running on a clustered windows server 2003 enterprise edition, and the clients are windows xp pro.
sorry about the delay, the script is running on a clustered windows server 2003 enterprise edition, and the clients are windows xp pro.
ASKER
as far as the error per machine,
it pops up after the logon, and it occurs on most machines.
it pops up after the logon, and it occurs on most machines.
Do you still get an error with the latest code?
Rob.
Rob.
pk24573, seeing as you are still having issues with this, I will post this comment as an objection to stop the closure of the post.
I think the
Input past end of file (800a003e)
might be something to do with reading a file that has nothing in it (so did anything get writen to the file in the first place? try echoing out the result to see on the machine with the problem)
The permission denied could be when tryin gto ddelete the temp file that is created in the IP function
Just a guess on that one
Krystian