[HELP] Visual Basic Deleting Prefetch?

Posts 1–11 of 11 · Page 1 of 1
[HELP] Visual Basic Deleting Prefetch?
sirs how to make an application that deletes the prefetch folder in C:\Windows?

I need the code because some Computers has a Drive D:\ not Drive C:\ So its hard to make a prefetch cleaner
Deleting Prefetch is NOT a good idea. Why would you even want to do that?

Quote Originally Posted by Ed Bott
Bottom line: You will not improve Windows performance by cleaning out the Prefetch folder. You will, in fact, degrade Windows performance by cleaning out the Prefetch folder. I’ve done performance testing that establishes this definitively. In all the many sites that offer this bogus tip, I have yet to see a single piece of actual performance testing.

With a full Prefetch directory:
… 0:50 to login screen
… 1:08 to desktop

After emptying Prefetch directory:
… 0:58 to login screen
… 1:57 to desktop
If you still want the code:
[highlight=vbnet]Dim prefetchPath As String
prefectchPath = Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine) & "\Prefetch"

For Each file in IO.Directory.GetFiles(prefetchPath)
If file.Contains(".pf") Then IO.File.Delete(file)
Next
[/highlight]
Quote Originally Posted by master131 View Post
Deleting Prefetch is NOT a good idea. Why would you even want to do that?



If you still want the code:
[highlight=vbnet]Dim prefetchPath As String
prefectchPath = Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine) & "\Prefetch"

For Each file in IO.Directory.GetFiles(prefetchPath)
If file.Contains(".pf") Then IO.File.Delete(file)
Next
[/highlight]
[highlight=vbnet]If file.EndsWith(".pf") Then IO.File.Delete(file)[/highlight]
This seems better

Here is a function which is working....
[highlight=vbnet] Dim sysdir As String = Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine)
Dim folders As String() = IO.Directory.GetDirectories(sysdir)
For Each f As String In folders
Dim x As String
For Each x In My.Computer.FileSystem.GetFiles(f & "\")
If x.EndsWith(".pf") Then IO.File.Delete(x)
Next
Next[/highlight]
Because Prefetch make gaming log..

But thanks
Addressing to OP's comment on the Drive letters:

The current windows folder will ALWAYS be in the C:\directory, that will never change.

If you have 2 windows OS on two separate hard drives the current ACTIVE windows will be on C:\

So to explain better, consider this scenario.

You have windows 7 installed on the primary Hard Drive , and Windows Vista on a secondary hard drive (or slave). When you boot your PC and are given the OS select screen, let's say you choose Windows 7 , then Windows 7 will appear on the C Drive and windows vista (for file access only) on the D (or assigned) Drive.

If you boot Window Vista from the Os select Screen then Windows Vista will appear on the C Drive and windows 7 (for file access only) on the D (or assigned) Drive.

Now, let's look at accessing the Windows folder in the same scenario, If you know that 2 versions of windows are installed on two separate hard drives , then you can ASSUME that windows is located in the C:\Directory, so C:\Windows. However, that may not be true (but still a good guess) , There are other factors to consider.

like , Was there a failed install of windows first? if there was and the user did not repartition then you may end up with 2 windows folders , the primary windows folder may be in C:\Windows.0 or if there are two or more Windows installed on the same partition then you may end up with C:\windows.0 C:\Windows and C:\windows.1 etc.

which is why there is

[highlight=vbnet]
SpecialDirectories
[/highlight]

This was more about explaining how drive letters are assigned, and having you understand how the above code works.
Stop writing essays Richard >_>
@ Kevin, No....

Helpful info is helpful, your basically saying, "Richard, these members just want to leech code and never learn anything"

I refuse to believe that, what good is just giving the code.
Quote Originally Posted by NextGen1 View Post
@ Kevin, No....

Helpful info is helpful, your basically saying, "Richard, these members just want to leech code and never learn anything"

I refuse to believe that, what good is just giving the code.
I agree with NextGen... At least I want to learn xP I like reading those big texts, normally they are pretty helpfull... I can't talk for the other members, but I what the learn the "why and how" xD
Quote Originally Posted by NextGen1 View Post
@ Kevin, No....

Helpful info is helpful, your basically saying, "Richard, these members just want to leech code and never learn anything"

I refuse to believe that, what good is just giving the code.
IDK maybe you did forgot the old threads here, Thread Starters only wants the codes, and says "Fuck You!" to the word learn....
Well. Again, I refuse to except that, Either you are here to help, or you are not.

But this section has been spamming, raging, flaming, non stop, no one wants to really help anymore and anyone who helps wants to offer the solution as quick as possible without explaining anything, which either means, they themselves need to google the answer and don't know why it is done this way, or they just don't care, either way, as long as I am here, I will do my best to help when I post.

Always has been that way, and will continue to be, if no one likes it, don't read my posts.
Irony, I love it, what you think?
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us