Solved

Setting time out for registry

Posted on 2006-07-02
5
285 Views
Last Modified: 2010-04-17
I have created a registry item in my java application. I want it to be removed after a specified time interval. It should be removed when if the program is not running also. Also it should be removed when the application is open and system got restarted.

How can I set the timeout??
0
Comment
Question by:sree032397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 250 total points
ID: 17030269
There is no capability in either the registry or in Windows to do housekeeping for registry items.  That means that you will need to perform any housekeeping yourself in your Java application.  While that is simple to do when your application is running, it's not possible to do when it's not.

The only solution to this that I can think of is to scehdule a periodic task to run your application (or a application that only checks on this situation) at certain intervals of your choosing.  Alternatively, you could write a SERVICE that runs all the time and simply checks the registry entries you are interested in and does the right thing.
0
 
LVL 3

Assisted Solution

by:Andre_Tertling
Andre_Tertling earned 250 total points
ID: 17035719
Creating a service for this task seems a bit oversized (just my two cents). It certainly is a solution but it costs some effort to design a nicely (and properly) working service (and it can't be done in Java, I guess). It's probably easier to make up some small maintainer application that gets added to the system scheduler (like suggested by jhance). That consumes less system resources (I still vote for sensible programming and resource usage in this era of more and more bloatware) and it is easier to maintain for the user.
0
 
LVL 3

Expert Comment

by:Andre_Tertling
ID: 17035735
Doh, clicked on submit too early.
Of course you can use the maintainer application to remove the registry entries after some timeout as well. Just launch the maintainer application with an appropriate command line parameter when you main program quits. The maintainer app will just sleep for the time span specified, clean up the registry and exit. Naturally, this requires that the user doesn't shut down the system or kill the helper application in the meantime. You could avoid such by hiding the helper process and storing re-run information in the autorun registry keys but once again, too much effort for a simple program, too dubious for the user and I'm sure one or another virus scanner will falsely report a virus in your helper application :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn different types of Android Layout and some basics of an Android App.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question