Close a DOS program without a windows pop-up "CANNOT END PROGRAM"
Posted on 2013-01-28
I'm using Visual Foxpro 9 vfp9 to control an old dos apllication AccPac Plus for DOS,
Sometimes the users leave an active application opened at night,
I found a way to track this behavior and to stop the program,
But I always have a message from Windows "CANNOT END PROGRAM" that requiers a manual intervention.
Is there a way to bypass this message or reply it programatically using VFP9?
The code to colse the program is:
oWMI = GETOBJECT('winmgmts://')
cQuery = "select * from win32_process where name='"+prog_to_stop+"'"
oResult = oWMI.ExecQuery(cQuery)
x = 0
FOR EACH oProcess IN oResult
x = x + 1
MESSAGEBOX(STR(x,5,0)+' programs were stopped')
TK ='!TASKKILL /FI "WINDOWTITLE EQ ' + prog_to_stop + '"'
MESSAGEBOX('No such programs were found active to be stopped')