Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cannot to copy an opened file : How to cut the link ?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Database:
Visual FoxPro
Divers
Thread ID:
01163699
Message ID:
01163722
Vues:
9
>My task is running at night, and sometimes some files (dbf) can stay opened. Then my task used to copy (and overwrite) a file was failed. Is exist a way, using WinAPI (or others) to kill the process or cut the link between an application and a file located on the same server as my task?


lcEXE = "ExeYouWantToKill.exe"
lcMachine = ""
lcMoniker = "winmgmts://" + IIF(!EMPTY(lcMachine),lcMachine + "/","")
oWMI = GETOBJECT(lcMoniker)
loProcesses = oWMI.InstancesOf("Win32_Process")
lcExe = LOWER(lcEXE)

FOR EACH loProcess in loProcesses
IF LOWER(loProcess.Name) = lcExe
loProcess.Terminate(0)
ENDIF
ENDFOR
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform