WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Error Codes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Error 1077. File Open: Open Failed

Keywords:  Error 1077 File Open Failed 

General Question on FileOpen:

I'm getting the 1077: FileOpen: Openfailed error during the second Call() pass of the first line of code below. I suspect that the FileClose() command is not executing at all, but I'm not aware of anyway to detect a successful FileClose(), nor do I know how to resolve. I have attempted TimeDelay() thinking that maybe it was a speed problem, but that does not help either. Any suggestions would be greatly appreciated.
        handle=FileOpen(tmpscrnfile,"WRITE")
        FileWrite(handle,crntscrn)
        ; TimeDelay(15)
        FileClose(handle)

        ; tmpscrnfile is a string containing a fully
        ; qualified path and file name.
        ;
        ; crntscrn is a string containing up to
        ; 3072 characters.

Answer:


Question on FileOpen and Compiling:

I'm getting this error message, when trying to recompile an EXE after a minor change in the WBT file, which from all appearances should not have caused any problems. I'm trying to compile to a network drive. Why is this happening?

Answer:

When Compiler tries to compile a WBT, it compiles the file in memory, and then when it goes to write the EXE file, it will report this error message, "Error 1077. File Open: Open Failed," if the old EXE of the same name, and in the same path, is unwriteable.

It could be unwriteable for a couple of reasons:

  1. The EXE file is Read-Only; or
  2. There is a lock on the EXE file you are trying to write to; or
  3. The EXE is already executing. Compiler cannot write to a file that is currently active.
What to do? Change the target filename or target directory of the EXE file, in the third option in the main Compiler window. If you do this, and the compile is now successful, then you know that one of the conditions above exists, and you can now go about your business tidying things up.

Question on FileOpen and Directory Names with Spaces:

I'm getting a 1077 error when I try something like this (under NT 4.0). fubar is a file. It chokes on the space in the "program file" directory name.
        zgsTempDir = "g:\temp\program files\fubar"
        zlifh = fileopen(zgsTempDir,"WRITE")
The directory is accessible, no files are open, permissions are ok, etc.

I need to do this since there is no such function to convert LFN directories into SFN ones without having to first create a file in the directory then do a FileNameShort to that file.

Answer:

Winbatch can indeed handle long file names.

Are you using the 16 bit version of WinBatch??? The 16 bit version indeed cannot handle long files names. Only the 32 bit version can.


Question on FileOpen - "There has been a delay in writing to filename. All data will be lost":

I just got a new machine here at work that has Windows XP installed on it. I have several scripts that perform FileOpen to append data to text files and dbf files that are on a network drive. The initial run of a script fails to open the file - File Open Failed. I've gotten a error from Windows XP stating that "There has been a delay in writing to filename. All data will be lost". When I go to the network drive and physically open the file that I am writing to then close it and rerun the script, there is no error. Plus, all subsequent scripts that use different files in other folders on that network drive run just fine. Files on the local machine do not have any problems writing to. I am running an older version of Winbatch - 2003H. Has anyone run in to this with Windows XP?

Answer:

I have run into that when the network card in the machine was flaky, or the hub port had problems.

User Reply:

Actually, it was a program that was installed on my computer - Cisco VPN Client. The default setting was Stateful Firewall (Always On). I uninstalled the program and everything is working now.

It turns out that the version of Cisco VPN Client that we use for Windows 2000 is incompatible with XP which did not help my problems. I contacted our system admins to get a new version of Cisco VPN client for XP. Apparently, the XP version has not made its way to the site install group yet.


Question on FileOpen and DiskKeeper:

I have a script that continually appends to a log file, everyonce in a while, I get an error message:
1077: FileOpen: Open failed 
On the line
loghand=FileOpen(logfile,"APPEND")
More error info gives me CreateFile error: 32

Answer:

Your program continually appends lines to a log file and it does this one line at a time, where it opens the file, writes one line, then closes the file. When it tries to write the log file, it sees that the file is currently in use.

Generally the two possibilities are that the file did not get closed from a previous write to the log file, or that some outside program decided to investigate the file and was presumably trying to read the file at the same time your script was trying to open the file for append.

There is a known issue with a product called DisKeeper. DisKeeper automatically defragments the file system behind the scenes. It may be getting its hands on the log file between calls to fileOpen in Append mode and FileClose, hence causing WinBatch to throw an error. As a workaround you can incorporate Error Handling using IntControl 73, then reattempt the FileOpen after a small TimeDelay().

We are considering a modification to our FileOpen function such that it would have the option to automatically retry for a period of time so that it can attempt to recover gracefully if another program decides to meddle with the files that a script is working with.


Article ID:   W12937
Filename:   1077 File Open Failed.txt
File Created: 2007:04:02:14:23:28
Last Updated: 2007:04:02:14:23:28