Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Terminate network user with PAL?

Status
Not open for further replies.

Eviltwin

Programmer
Apr 11, 2001
39
US
Greetings--
Is there a way to use PAL to terminate network user sessions?
Thanks
 
EvilTwin,

By "PAL," do you mean Paradox for DOS or Paradox for Windows?

Also, which version of Windows?

-- Lance
 
Hi Lance--
I am using Paradox 10 on a Windows 2000 platform.
 
Hi Lance--
Perhaps I should rephrase my question as well: Is it possible to terminate a user and/or useres paradox session on a network using objectpal?

We process our daily work using batches. At the end of the day we post the batch. If a user has left certain forms open then the batch will not post. So we then have to go to the station and close the form.
Thanks
 
EvelTwin,

A simple solution that comes to mind is to set up a timer event on the forms that need to be closed and have them close if they are open after a certain time.

If you want more control you can create a table with net user names and a logical field. Set your timer to periodically check the table and search for it's username using getnetusername() and if the logical field is set to True have the timer close the form or Paradox.

Perrin
 
Hi Kliot-:)
That sounds relatively simple. As far as any of this is simple.
Thanks
 
EvilTwin,

Yes, it's possible to do this, though you'll need a utility that shuts down the computer (or logs off the current user). Windows XP provides one with the OS (shutdown.exe can be found in \WINDOWS\SYSTEM32); it's also available for Win 2K/NT4, but you'll need the appropriate Windows Resource Kit from MS to get it. MS documents the resource kit utility at though you may want to review for some corrected details.)

Alternatively, offers a free utility for NT, Win 2K, and XP. (Please note that Win9.x is *not* supported.)

In any event, the basic idea is to either log off the user or to reboot the machine after shutting down (which closes the applications). You can set this up to automatically happen at a set time after the end of the work day but before your automated tasks start. Use either Schedule Tasks or the AT utility (see the MSDN article posted earlier).

Alternatively, Perrin's idea is a good one, e.g. adding code to a form's timer to automatically close the form after a set period of time of inactivity.

Let's define "activity" as a keyboard or mouse event. That done, here's how you can set this up for an individual form:

1. Open your form in Design mode and then declare the following in the form object's Var window:

Code:
Var
   tLastAction  Time
endVar

2. Open the form's init event and then add the following code:

Code:
method init(var eventInfo Event)

   tLastAction = time()
   self.setTimer( 1000 )

endMethod

3. Open the form's keyChar event and then add the following code:

Code:
method keyChar(var eventInfo KeyEvent)

   if not eventInfo.isPreFilter() then
      tLastAction = time()
   endIf

endMethod

4. Open the form's keyPhysical event and then add the following code:

Code:
method keyPhysical(var eventInfo KeyEvent)

   if not eventInfo.isPreFilter() then
      tLastAction = time()
   endIf

endMethod

5. Open the form's mouseDown event and then add the following code:

Code:
method mouseDown(var eventInfo MouseEvent)

   if not eventInfo.isPreFilter() then
      tLastAction = time()
   endIf

endMethod

6. Open the form's mouseMove event and then add the following code:

Code:
method mouseMove(var eventInfo MouseEvent)

   if not eventInfo.isPreFilter() then
      tLastAction = time()
   endIf

endMethod

7. Open the form's timer() event and then add the following code:

Code:
method timer(var eventInfo TimerEvent)
var
   tIdleTime  Time
endVar

   if not eventInfo.isPreFilter() then

      tIdleTime = ( time() - tLastAction )
      if tIdleTime.hour() > 0 then
         self.killTimer()
         formReturn( FALSE )
      endIf
      
   endIf

endMethod

8. Save and run your form.

As you can probably tell, this form essentially does two things:

1. It saves the time of the user's last direct interaction with the form, via the keyboard or the mouse.

2. It starts a timer that compares the current time to the time of the user's last activity. When that exceeds an hour, the form is closed.

There are a few things to keep in mind when using this:

-- Note that I reworked the default code that Paradox normally adds to a form-level event. The main idea is to update the activity time when the form receives a keyboard or mouse event.

-- Paradox doesn't first keyboard events for the Shift, Ctrl, or Alt keys, except when those keys are used in conjunction with other keys on the keyboard. Pressing Shift+A generates an event, but pressing and release Shift doesn't.

-- You can exit Paradox by replacing the self.close() with exit(); however, be aware that a) if the form has been modified, Paradox will prompt for saving. This is not typically a problem; however, if it becomes a problem, you can clear the DesignModified property to avoid the prompt--just understand that your unsaved changes will be discarded.

Use something like this to clear DesignModified:

Code:
if DesignModified then
   DesignModified = FALSE
endIf

-- I used formReturn() to close the form instead of close() in case your form is in a wait() state.

Hope this helps...

-- Lance
 
Hi Footpad--
Wow! Step by step tutorial even. This looks like it will achieve the results I am looking for.
Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top