tags:

views:

120

answers:

2

One of our clients has been having a lot of network problems lately. When I went to retrieve the errors text file on their server computer I discovered about a dozen files, one was the correctly named file

"errors.txt"

but the others had names like

"errors (computernameA v1).txt"

"errors (computernameA v2).txt"

"errors (computernameB v1).txt" etc etc.

Our software is definitely not creating files with these names although it is creating their content.

The network being down will obviously throw errors in very many places in the client application. Part of the handling of all errors is to log them to the server computer. The routine that does this first tries to find the error file and if it can't do so it tries to create it. Some of these other error files contain a lot of errors suggesting that a local 'shadow' of the error.txt being used for successive errors while the network was down over a not insignicant time period? then once the network is back up again this is being put onto the server and renamed so as not to clash with existing file names

can someone please explain what's happening here and what software is doing it?

edit

In response to a request for the relevant code

170   On Error Resume Next
      Dim fs
180    Set fs = CreateObject("Scripting.FileSystemObject")
       Dim Item1 As String
       Dim Item2 As String
190    Item1 = strErrorFolder
200    If fs.FolderExists(strErrorFolder) <> True Then
210           MkDir Item1
220    End If

230    Item1 = strErrorFolder & "\Errors.txt"
240    If fs.FileExists(Item1) <> True Then
250    Item2 = App.Path & "Blank.txt"
260           FileCopy Item2, Item1
270           Item2 = ""
280           SetAttr Item1, vbNormal
290           Open Item1 For Output As #1
300           Write #1, "ErrorDateTime", "ErrorUser", "DatabaseAddress", "ProgramVersion", "Module", "SubRoutine", "LineNumber", "ErrorCode", "ErrorDescription"
310           Close #1
320    End If

330    Open Item1 For Append As #1
340           Write #1, ErrorDateTime, ErrorUser, Left(PANDATABASE, 1), ProgramVersion, Module, SubRoutine, LineNumber, ErrorCode, ErrorDescription
350           Close #1

360   On Error GoTo 0

End Sub 'errorhandled not
+1  A: 

Run FileMon on the machine an then cause the error condition. Check the FileMon log to see what created the files.

As divo pointed out, you may need to use ProcMon instead.

EBGreen
I may yet do that, Thanks. I was hoping that there might be some automatic network admin behaviour to explain it
kjack
The use of FileMon is no longer recommended (and the tool is no longer supported). It's better to use its successor ProcMon.
0xA3
Ehh...that is true, but as long as it works I still use FileMon. There is enough data to wade through with FileMon that I avoid the overkill of ProcMon unless I can't avoid it.
EBGreen
However, not all current Windows platforms are supported by FileMon, e.g. Win XP SP3 or Win 2k8 are not listed. So there is a chance that the results displayed by FileMon are no longer accurate on these platforms. I agree though that performance of ProcMon could be better...
0xA3
That would be the "...as long as it works..." part. :)
EBGreen
I'll bet it's some kind of file synchronization or backup program. Filemon/Procmon will show this but you'll have to be patient.
jdigital
+1  A: 

This is a stab in the dark. Try replacing

Item1 = strErrorFolder & "\Errors.txt"
Item2 = App.Path & "Blank.txt"

with

Item1 = fs.BuildPath(strErrorFolder, "\Errors.txt")
Item2 = fs.BuildPath(App.Path,"Blank.txt")

An alternative form of debugging add a configuration option to the software that allows you to uniquely ID each install of the software. Incorporate it into the error file name. That way you can see where each error file is coming from.

RS Conley
Thanks, especially for your suggestion about adding extra information to the error log.
kjack
I'm as certain as I can be that these extra files are being created by my software. It's the mechanism of how they are brought over to the server and renamed once the network is up again that mystifies me.The users are not technical in any way.
kjack
Also while the network is down the attempts to create the file should be failing. It's like the software is being fooled into believing that its attempt to create the file was successful.
kjack
It may be that a mechanism similar to what happens when you paste a duplicate file with a duplicate name. Windows is intercepting the creation call and altering the name to prevent overwrites.
RS Conley
By making sure each user's error log has a unique game you can see if this is what happening. If the problem disappears with the unique name then that your culprit.
RS Conley
You can then further explore this issue by writing test software and run it on different machines. The test software will be trying to save files to the same name on the server.
RS Conley
This is totally separate but you do know that in VB you don't need line numbers.
RS Conley
Oh by extra information I mean to the FILE NAME. After you figure out what is happening you can try to revert back to using a common name.
RS Conley
OK I misread you the first time, thanks for that. The windows intercept analogy sounds right.
kjack
Could there be further a mechanism where windows on the client computer would fool an app into thinking that a network file had been created by that app and then keep that "network" file available for further appending until the network was restored?
kjack
PS : Line numbers only put in source before release using the wondrous MZ tools (for error info)
kjack
I haven't heard of that behavior. But then over the years I maintained my metal cutting software in VB6 I seen many strange changes. I wouldn't rule it out. Again the way I solved these type of problems is writing minimal apps so I understand what actually going on
RS Conley
The good news once are able to define what going then you probably have what you need to create a effective Google search to read up on the issue
RS Conley
Thanks again for your help. If I get to the bottom of it I'll put it up
kjack
Good advice from RS Conley. I'd also suggest removing the on error resume next, or at least logging any errors in the error reporting somewhere (locally?) then doing resume next. You might be swallowing important info with the on error resume next
MarkJ
That might be an idea alright. Thanks MarkJ. RS Conley always gives well thought out comprehensive answers imo.
kjack