I came across some code which I've been looking for for a long time.
i.e. WHO has WHAT files open, and close them if you want
I have just 1 problem with it. When I list the open files, it doesn't show
the Executablethat opened the tables in the 1st place
(Winkiss.exe)
Does anyone wish to comment ?
DO makedbf && creates a temporary table, myfile
CLOSE DATABASES
CREATE CURSOR junkopen (xID I, xuser c(10), xsystem c(10), xfiles c(100),
xselect L)
LOCAL oShell as wscript.shell, lcTempFile
lcTempFile = myfile+".txt"
oShell = createobject("WScript.Shell")
* create a CSV list of open files in server
oshell.Run("cmd /c openfiles /query /S myservername /U administrator /FO
CSV /NH > "+m.lcTempFile,2,.T.)
* Clean it up, remove those warnings above the list
*STRTOFILE(STREXTRACT(FILETOSTR(m.lcTempFile),"again.."),(m.lcTempFile))
* do this if testing
*MODIFY FILE (m.lctempfile)
* add records to our cursor
APPEND FROM (m.lcTempfile) TYPE CSV
* Clean it up
SELECT xfiles, xID, xselect FROM junkopen WHERE ;
(INLIST(UPPER(JUSTEXT(xfiles)),"DBF","CDX","APP","FPT") OR
INLIST(UPPER(xfiles),"WINKISS.EXE")) AND !EMPTY(JUSTEXT(xfiles)) INTO TABLE
junkagain
USE
CLOSE DATABASES
SELECT 1
USE junkagain EXCLUSIVE
DO FORM trwhohas &&where you select what files you want to close
go top
scan
if xselect
oShell.Run("CMD /C OPENFILES /DISCONNECT /S myservername /ID
"+TRANSFORM(junkagain.xID),2,.T.)
endif
ENDSCAN
CLOSE DATABASES
DELETE FILE("junkopen.dbf")
DELETE FILE("junkagain.dbf")
-
Regards
Sytze de Boer
Kiss Software
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/cag1nny9xefyw6ryiaoz7mslsjiovwd+g-fwho06n_k6blsu...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.