WinBatch® Technical Support Forum

Archived Boards => Network Extenders => Topic started by: snowsnowsnow on October 31, 2014, 07:23:35 AM

Title: How to close an open file from WB script?
Post by: snowsnowsnow on October 31, 2014, 07:23:35 AM
Remind me which functions to use to do this.

I have a WB script that opens a log file periodically to append info.  Normally, it works fine, but it failed today (with error 32) because I had accessed the file from another machine (via Windows Networking).  The other machine had long since closed the file, of course, but Windows Networking keeps it open long after the other machine has closed out of the app.

I can fix the problem by going into compmgmt.msc and closing the open file.  But I would like to do that programmatically - when the open fails, I'd like to invoke whatever's necessary to close the file. I could, of course, do it by automating the compmgmt.msc GUI, but it'd be better to do it with the Network Extender.
Title: Re: How to close an open file from WB script?
Post by: td on October 31, 2014, 07:53:58 AM
Give 'wntFileClose' a try.
Title: Re: How to close an open file from WB script?
Post by: snowsnowsnow on October 31, 2014, 08:52:28 AM
Quote from: td on October 31, 2014, 07:53:58 AM
Give 'wntFileClose' a try.

Yeah, that looks like it will do it.

BTW, can't help but nitpick this line from the "help" for that function.
Looks like badly translated "not quite English":


Note: this function will not work to do a wntFileClose on a local file that was opened by yourself on the local machine, even if it's done over a mapped drive with a UNC.
Title: Re: How to close an open file from WB script?
Post by: td on October 31, 2014, 12:58:20 PM
It does read a bit like the user manual to that made in Guangzhou whatever you just bought at MalWart. Although the I am pretty sure the author considers English a first language.   
Title: Re: How to close an open file from WB script?
Post by: snowsnowsnow on October 31, 2014, 03:30:32 PM
Heh heh.

MalWart - gotta love it!
Title: Re: How to close an open file from WB script?
Post by: ChuckC on November 01, 2014, 07:36:12 AM
Oh, yeah, there used to be a bumper sticker you could get that said, "Mal-Wart: Plastic Crap Sold Cheap"


Tony - I had to go back and check the help topic text for wntFileClose() just to see if that was one of mine, or not.  Looking at the topic's text, though, I'm thinking it was actually one of Marty's.
Title: Re: How to close an open file from WB script?
Post by: td on November 01, 2014, 09:02:38 AM
I wasn't trying to point a finger.  I have uncorked to many gems to presume the right to castigate the elucidative skills of any scribe.