close everything DF on the machine
With having WFH people, we've seen a gradual loss of discipline as regards closing programs overnight, so I'm reviving my interest in building a blow-away-everything-dataflex on a timer that runs on every workstation.
I recall several discussions on this over the years, but the keywords I'm searching for are not finding any matches (maybe 'kill' and 'destroy' are being filtered out by law enforcement...)
So I'll start again. Does anyone have a kill switch built into their windows programs? (I'm interested in approaches as much as in actual code)
Re: close everything DF on the machine
I use a timer that's already in the app to display the date & time. It calls a dialog that shuts the app down, but gives the user a chance to cancel.
Re: close everything DF on the machine
[QUOTE=Garret Mott;368967]I use a timer that's already in the app to display the date & time. It calls a dialog that shuts the app down, but gives the user a chance to cancel.[/QUOTE]
I want this to be silent, or almost silent.
Every program starting checks if 'killswitch' - a background program is running and if not starts it.
'killswitch' checks immediately it starts and every x minutes thereafter against a control file and/or the clock if systems are allowed to be up.
If the answer is no then it forcibly closes every dataflex program (data loss or not), on that machine and leaves a cartoon grim reaper displayed. (last bit optional but unlikely).
IT can edit the control file remotely to alter the times allowed, should exceptions be required. We open very late at xmas, for instance.
Re: close everything DF on the machine
We've had an individual program inactivity time-out in place for years but frankly it just frustrates those who want to run a program several times on the trot with similar inputs (say sales jan-dec for store1 then store 2, store 3 through store21 etc).
Better to say all systems stop 9pm-6am. Relying on AD to lock users out seems to not close databases so an OS approach doesn't work either.
Re: close everything DF on the machine
Maybe just save the datetime in a global var when the program starts en then just have a timer check a database field containing a datetime and kill itself when start datetime < kill datetime.
Then you could just update the db field and all apps started prior would kill themselves.
Re: close everything DF on the machine
Done something similar, works well unless the application is displaying modal dialog - then the timer is suspended until the user to close the dialog.
A separate app that the DF apps register with when they start is best as this monitor app can ask Windows to kill the process. And no I have not implemented this – sorry.
Re: close everything DF on the machine
I had silent, but got a (loud) complaint from a manager who was working @ 4:00AM & was ticked about getting booted. So, I added the dialog with its own 30 second countdown. If the user does not click anything, it then shuts down.
While I have the time hard-coded, it could certainly be in a system file or the like.
Re: close everything DF on the machine
[QUOTE=Garret Mott;368977]I had silent, but got a (loud) complaint from a manager who was working @ 4:00AM & was ticked about getting booted. So, I added the dialog with its own 30 second countdown. If the user does not click anything, it then shuts down.
While I have the time hard-coded, it could certainly be in a system file or the like.[/QUOTE]
how does that work if that program also has modalpanels, stopboxes, etc, open?
Re: close everything DF on the machine
I just tried it with a modaldialog up. While I wasn't here to watch it, when I got back to the confuser the app was shut down
1 Attachment(s)
Re: close everything DF on the machine
I tried again while watching. Seems to work just fine. In the pic, there's a view with a lookup open on the screen & then the shutdown dialog pops up at the set time. It stayed up for the 30 seconds & then shut down the app.
[ATTACH=CONFIG]14972[/ATTACH]
The code that actually shuts everything down (& sets the display msg) is:
[code]
Object oDFTimer1 is a DFTimer
Set TimeOut to 1000
Procedure OnTimer Integer wParam Integer lParam
Integer iCount
Forward Send OnTimer wParam lParam
Get piCount to iCount
Decrement iCount
Set piCount to iCount
If (iCount > 0) Begin // will keep -1 from displaying
Set Value of oTextBox1 to ("Shut Down in " + String(iCount) + " Seconds")
End
If (iCount <= 0) Begin
Set Timer_Active_State of odftimer1 to False
Send Deactivate of Desktop
Abort
End
End_Procedure
End_Object
[/code]