Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Once again, i request some assistance.

A good idea floated into my head just now of making a Registry Cleaner program.
I once made a program that deletes files from the Temporary Files folder, but that was boring.
How can the algorithm know what needs cleaning from the registry?
-and how can I trigger User Account Control to give admin access to the registry?

Much appreciated as long as nobody deletes my question because "this question is too vague " and "there is nothing to discuss here" .

:)
Posted
Comments
Richard C Bishop 13-Mar-13 14:22pm    
Algorithms don't know anything. They are programmed to do everything they do. You are correct, your question does not provide enough information for anyone to help. You are basically asking for someone to do the work for you.
joshrduncan2012 13-Mar-13 14:34pm    
I highly suggest OP find an opensource setup and modify it to fit what he's looking for.
Richard C Bishop 13-Mar-13 14:36pm    
Indeed, that would be a safer solution.
Sergey Alexandrovich Kryukov 13-Mar-13 14:23pm    
Yet another one? Why? We already have some free software which takes care about this important clean-up.
I don't think there is single algorithm. Rather, this is a number system-specific chores.
—SA
[no name] 13-Mar-13 14:24pm    
This is going to sound horribly mean but I really do not mean it that way. Just so I understand.... you have to ask how to get the user to input an IP address in your program as in this question, http://www.codeproject.com/Questions/561447/HowplusshouldplusIpluschangeplusthispluscodeplusto, and you are going to take on messing with the registry? Don't you think that you should figure out the incredibly easy before taking on the incredibly difficult?

Please see my comment to the question. I think this is not the question to be answered in the forum. It's rather a research and development work to be done. The only reasonable answer would be just doing a considerable part of this work, with, please understand it, would be a bit too much for a forum.

And deleting anything from temporary folder does not really clean the registry. Unfortunately, cleaning the registry is really needed, but this is quite a complex and dangerous activity. If you really want to do it, you have to learn a good deal of system internals, not just techniques, which are actually quite simple. Basically, you need to find out all potential cases of registry inconsistencies and the way of making the registry data self-consistent.

Some inconsistencies are very apparent: for example, you can easily get a lot of data elements pointing to some physically removed files (for example, formally install some software and then remove executable directory; how to return to the consistent Registry as it was before installation?). You can always remove those entries pointing to non-existing files, but how much to remove around them? This is a problem requiring detailed knowledge of relevant registry-stored structures. Many are documented, but I believe some are not. At the very least, you need to do a lot of experiments on the systems you can always rebuild if you screw up. A lot of work, I would say.

I think the only part which makes sense is the last question, about the administrative access. You will really need elevated privileges. In Windows 7 and later (should I even mention such broken thing as Vista? :-)), having administrative account is not enough. You also will need to ask a user confirmation via UAC:
http://en.wikipedia.org/wiki/User_Account_Control[^].

Normally, you can run anything "as administrator" on the user level, if your account has sufficient privileges:
http://4sysops.com/archives/vista%E2%80%99s-uac-8-ways-how-to-elevate-an-application-to-run-it-with-administrator-rights/[^],
http://www.sevenforums.com/tutorials/11841-run-administrator.html[^].

However, for a system utility this is not good enough, as you always need to "run anything as administrator". So, the right thing would be adding the request right to the application manifest. Please see:
http://msdn.microsoft.com/en-us/library/bb756929.aspx[^].

That's all.

—SA
 
Share this answer
 
v3
Comments
joshrduncan2012 13-Mar-13 14:41pm    
+5 from me. :)
Sergey Alexandrovich Kryukov 13-Mar-13 14:42pm    
Thank you very much.
—SA
[no name] 13-Mar-13 14:45pm    
yes, i have worked with manifests before.
I'll look into it.
If you only need to remove temporary files, you need to use the directories you can access via the following API:
http://msdn.microsoft.com/en-us/library/14tx8hby.aspx[^],
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx[^],
http://msdn.microsoft.com/en-us/library/aa364992%28VS.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx[^].

And also System.Environment.GetEnvironmentVariable("TEMP").

As to your idea to search for "*.tmp" starting from "C:", this is not a valid idea: 1) you have other disks, so you would not to fetch their list first, 2) you may not have the disk "C:" (don't be surprised, who told you it should be there? I have one Windows system without "C:" right now), 3) you cannot guarantee that all "*.tmp" files were meant to be temporary.

—SA
 
Share this answer
 
Comments
[no name] 17-Mar-13 12:30pm    
so how does a computer cleaning program know what to delete?
Sergey Alexandrovich Kryukov 17-Mar-13 20:57pm    
It's a big question. For example, is some entry points to non-existing file (which is a usual case: you can delete a file, but the registry entry still points to it); then it's apparent that this entry is not needed anymore. In this extent, the program logically resembles a Garbage Collector. In a way, it is.
—SA
[no name] 18-Mar-13 13:30pm    
i made a dead shortcut deleter before, but that didn't really speed up the system...
Sergey Alexandrovich Kryukov 18-Mar-13 13:52pm    
Sorry, I don't know what's "dead shortcut". Will you explain? Why would expect to speed up anything?
—SA
[no name] 18-Mar-13 13:55pm    
well, when a shortcut target is non-existant, it is a dead shortcut. So i listed all *.lnk files and did a try-catch-end try statement. if they did not open, they would be deleted.
Registry cleaning is supposed to speed up the system
And please look at my new question called Compressing Base64 Strings :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900