Author Topic: How to close an open file from WB script?  (Read 2391 times)

snowsnowsnow

  • Full Member
  • ***
  • Posts: 230
How to close an open file from WB script?
« 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.

td

  • Tech Support
  • *****
  • Posts: 2057
    • WinBatch
Re: How to close an open file from WB script?
« Reply #1 on: October 31, 2014, 07:53:58 am »
Give 'wntFileClose' a try.
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


snowsnowsnow

  • Full Member
  • ***
  • Posts: 230
Re: How to close an open file from WB script?
« Reply #2 on: October 31, 2014, 08:52:28 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

  • Tech Support
  • *****
  • Posts: 2057
    • WinBatch
Re: How to close an open file from WB script?
« Reply #3 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.   
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


snowsnowsnow

  • Full Member
  • ***
  • Posts: 230
Re: How to close an open file from WB script?
« Reply #4 on: October 31, 2014, 03:30:32 pm »
Heh heh.

MalWart - gotta love it!

ChuckC

  • Full Member
  • ***
  • Posts: 112
Re: How to close an open file from WB script?
« Reply #5 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.

td

  • Tech Support
  • *****
  • Posts: 2057
    • WinBatch
Re: How to close an open file from WB script?
« Reply #6 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. 
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams