Controlling the system's time


I am writing an application that takes the system time and does some caculations. The app will calculate how much time the employee was at work.

The app will be installed on one PC. The app generaly has two bottons; "In" "Out". Every morning the employee will enter his name and will click the IN bottun. And at the end of his work he will click OUT.

The app will work on win9x nt and xp

The problem is that if the user will be able to change the system's time than the app is worthless.

How do I overcome that?

(Please don't tell me "atomic clock" since the pc is not connected to the Internet. also hiding the clock can be unhide or can be changed with time command)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'm not sure if there is anything you could do through the interface that an employee couldn't undo. There could be a way that you could set a conditional in your progam. You could use this algorithim - if time is changed, set correct time. This way the employee would have no chance of punching out or in with the time changed.

 I am not sure what programming language you are using, so I can't find any code snippets. Hopefully this helps, though.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zolpoAuthor Commented:
Thanks DaVx0r!

Visual Basic 6

Your comment is interesting. I will appreciate your snippets too.

First off, set a BIOS system/admin password.

Then install TweakUI ( and disable the ControlPanel and anything else you think appropriate.

Modify the time collector to do a reboot when it is closed and have it load at boot.

It's not fool-proof, but it will keep honest people honest and deter all but the most determined plodder.

A key stroke grabber may be of some value.

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

the easyest thing is to:
1 - programs start:
     create a variable to store the ACTUAL time  (StartTime)
     create a variable to store a value (TimeWorking)
     start a timer, and each second, increment the timer, so will have the time that the user is connected
2- Programs ends:
    stop the timer
    Get the Actual Time and compare it with the StartTime+TimeWorking,
      if = everything is allrigth, you got the start time, and end time
      if != the user tried to cheat, but still have the hours he's been working, and the Start Time, so you can guess the   end  time and Remark he tried to cheat

the key is store the time that the app has been running

zolpoAuthor Commented:

Thank you so much for your brilliant contribution!

I can think now on a program that runs on the taskbar and calculate the variables you figured.

But some questions are left: What if the employee will close the app, change the clock than fire it up etc? Or accidently someone close the app or system crash etc. How do I maintain these situations? Not mention when there are 10 employees, should I fire up 10 timers?

BTW sometimes we can involve some DB consistency here; since every record has its time stamp, when a NEW record is older than an OLDER one there is a cheat here... probably.
>What if the employee will close the app, change the clock than fire it up etc?
while the timer is running, you can save every second the  TimeWorking value + the user that logged onto the computer, in a FILE, or in the registry, so each time the app is opened again, it cat get the old values.., or split your app in 2 parts:
a part that "intercats with the user" and a part that counts the time, so even is the user closes the 1º part, the time will still be runnig.. is the sistem crashes.. well thats a little bit more dificult.. but the "save in a file" option would still be aceptable..

is there are many users you can, use only one timer, but  you need TimeWorking variable, and a StartTime variable for each user, after all.. a second is a second :)

zolpoAuthor Commented:
RocketMan801 thank you again.

I will be back in a few hours.
personally I would purchase some type od devices that could be attached to the computer that has a readable clock.  The X10 interfacce for example.  When I needed to know what time it was I would query that device and ignore the system time.  I would just make sure that the software for loading the time into the external device was not loaded.
Here's a description of how to use the policy editor on Win9x to implement userid based restrictions.
To ensure that the current date/time on the application PC is correct you can set it with values from a trusted PC on the same network as folllows:

net time \\TrustedPC /set /yes

Where TrustedPC is the name of a PC on your network that can function as a "time server" to make sure the date/time on your application PC is correct.

If you execute this command after the user clicks the "In" and "Out" buttons the application PC will have its date/time set to a known valid value that you can trust.
zolpoAuthor Commented:

"personally I would purchase some type od devices that could be attached to the computer that has a readable clock."

Can you please be more specific;  can you supply some links to external (or internal) devices which will handle the system's clock.

zolpoAuthor Commented:

I like your link. Give me please some time to learn it.


But when the PC stands alone we cannot use it. Thank you again for that briliant solution!!!
X10 has a programmable controller that is relatively easy to read

motorola makes a number of external modems with clocks

And a quick google search showed me a number of fingerprint/time readers for USB ports
BTW, here is one that I have used
Rocketman801's solution becomes harder to subvert if you run it as a service. How you do that will depend on the tools you're using for development.
zolpoAuthor Commented:
Thank you for your help.

The points allocated accourding to your participation.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.