• Post Reply Bookmark Topic Watch Topic
  • New Topic

PC Switched On time  RSS feed

 
Indira Devi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hee everyone,
How can i know the my PC's previous switching on time using Java code?i.e if somebody had switched on my PC and shut it down and later when i swicth it on, i would like to know the previous instances switch on time.
Can anybody please help me?
Regards
Thanks in advance
Indira.
 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
save the time of start of ur pc in a file on hard disk
then check it when ever u want
 
Indira Devi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Actually my system is used by 3 people.So when one of the other
two guys switches it ON, I possibly can't store it in a file.
Kindly suggest a solution in this case.
Thanks in advance
Indira.
 
John Bateman
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
First off you should be able to check when anyone last logged on if you are the admin of your machine. But, I am also assuming your system is NT, Windows 2000 or one of the Unix flavors as a basis for this statement.
If you are using Win 95, 95 or ME then I don't beleive you will be able to do this without writing your own little app.
ALL IS NOT LOST.
Create am app that makes a file everytime the computer boots. I.E. put this file (to auto run) in the startup folder of everyone menus or stick it into the .login file if you are using a 'Unix flavor'.
This app should make a file that keeps track of date/times of when the computer starts. Since it runs on 'boot' or 'login' you will get all the times that someone has started up your machine.
Make sure they you hide (security by obscurity) this file and/or setup the permissions of this file proerly or your 'roomates' can edit it on you.
If you are REALLY worried about people using your computer, I would get a system that has security like Linux/BSD, or Windows NT/2000. These kinds of logging are all built in.
Hope this helps.
 
George Brown
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is JavaRanch, why not use java for the app that John is suggesting. For example, a nice 'n' simple way to do this is:

then if you are using one of the crappier Windows OSes (Win3.1/Win95/Win98/WinME), edit the boot script (autoexec.bat?) and after setting up your path and classpath for java, add the command to output the time:
java TimeStamp >> boottime.txt
So each time the system is booted, another line will be added to the boottime.txt file.
(of course, the path of the file is another question...)
Ultimately, as already suggested, an NT/UNIX/Linux/BSD system would be more secure and the solution could be more elegant.
[This message has been edited by George Brown (edited March 15, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!