In my app, i do have a routine that checks for 'shutdown.txt' and will automatically make the app close etc..
however, sometimes, for whatever reason, we get a user where there couple files are open etc..
i saw this routine on "Sandstorm's blog"
Is it safe to "kill" open dbf files and dbc files?
how about data corruptions and index corruptions?
anyone used this technique? or something similar
Ali Koumaiha
TeknoSoft Inc.
Michigan
however, sometimes, for whatever reason, we get a user where there couple files are open etc..
i saw this routine on "Sandstorm's blog"
Is it safe to "kill" open dbf files and dbc files?
how about data corruptions and index corruptions?
anyone used this technique? or something similar
Code:
CREATE CURSOR junkopen (xID I, xuser c(10), xsystem c(10), xfiles c(100))
LOCAL oShell as wscript.shell, lcTempFile
lcTempFile = ADDBS(GETENV("TMP"))+SYS(3)+".txt"
oShell = createobject("WScript.Shell")
* create a CSV list of open files in server
oshell.Run("cmd /c openfiles /query /S < your server name > /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))
* add records to our cursor
APPEND FROM (m.lcTempfile) TYPE CSV
* Clean it up
SELECT xfiles, xID FROM junkopen WHERE INLIST(UPPER(JUSTEXT(xfiles)),"DBF","CDX","APP","FPT") AND !EMPTY(JUSTEXT(xfiles)) INTO CURSOR junkopen
* Start closing remaining files on the list
SCAN
WAIT WINDOW "Attempting to close "+ALLTRIM(junkopen.xfiles) NOWAIT
oShell.Run("CMD /C OPENFILES /DISCONNECT /S < your server name > /ID "+TRANSFORM(junkopen.xID),2,.T.)
ENDSCAN
MESSAGEBOX("Target Open Files has been closed!")
* Perform your backup routine
Ali Koumaiha
TeknoSoft Inc.
Michigan