How to close an open file from WB script?

Started by snowsnowsnow, October 31, 2014, 07:23:35 AM

Previous topic - Next topic

snowsnowsnow

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.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

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.

td

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.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow


ChuckC

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.

td

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. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade