Wednesday, July 25, 2007

How to fix Vista driver cache

I've installed Vista on 3 machines now, and on all 3 something I've done has caused the Vista driver cache to become corrupt. So, when plugging in a USB device which it should recognize automatically, it instead says "Driver not found" and gives me options to repair it. While you can tell it to browse for a location manually, and choose c:\windows to get around this, I have created a batch file which will allow you to force Vista to rebuild the driver cache. You have to be an administrator on your system to use it, and it works with UAC enabled.

Create a batch file with the following content and execute it as an administrator (Right click it, choose Run as Administrator). It will create a directory labeled \windows\inf\infbk-XXXX (where the XXXX is replaced with a random number), set the relevant files to be owned by "Administrators", give "Administrators" full control over the files, and move them to the backup folder. After running this you should be able to just plug in a new device, although you might want to reboot first.

Here is the content of the batch file:
@echo off
TITLE Repairing Inf Cache
rem change to drive where windows runs
%SystemDrive%
rem change to the \windows\inf folder
cd %SystemRoot%\inf

rem create random directory for backup
set FOLDERNAME=infbk-%RANDOM%
mkdir %FOLDERNAME%

rem list of files which need to be removed
set FILE1=INFPUB.DAT
set FILE2=INFSTOR.DAT
set FILE3=INFSTRNG.DAT
set FILE4=INFCACHE.*
set FILE5=SETUPAPI.*

rem take ownership of the first file
takeown /f %FILE1%
rem grant full control to 'administrators'
icacls %FILE1% /grant administrators:F /t
rem move it to the backup folder
move %FILE1% %FOLDERNAME%

rem same for the other files
takeown /f %FILE2%
icacls %FILE2% /grant administrators:F /t
move %FILE2% %FOLDERNAME%

takeown /f %FILE3%
icacls %FILE3% /grant administrators:F /t
move %FILE3% %FOLDERNAME%

takeown /f %FILE4%
icacls %FILE4% /grant administrators:F /t
move %FILE4% %FOLDERNAME%

takeown /f %FILE5%
icacls %FILE5% /grant administrators:F /t
move %FILE5% %FOLDERNAME%

echo Successfully moved all infcache related files to %FOLDERNAME%
pause

Labels:

59 Comments:

At 6:59 PM, Blogger Inactive said...

*finally* a solution to this problem that "just works". No turning off UNC, no trying to follow instructions that someone said 'worked for him', but a simple, quick answer that finally did the trick for me.

Thanks!

 
At 6:58 AM, Anonymous Anonymous said...

Thank You Very Much!!! I've been struggling with my USB mouse for days now. And thanks to you HowTo, I got it up and running. Thanks again.

 
At 7:17 AM, Anonymous Anonymous said...

omg it worked, it worked... Ohhh my gawd it worked! For weeks I've been struggling with this and now my problem has been fixed.

Thanks, thank you so much!!

 
At 12:26 PM, Anonymous Anonymous said...

Which are the relevant files ?

Thank you for your help

 
At 9:05 PM, Blogger ShiftHappens 11:11 said...

What do you mean, "move them to the backup folder"?

 
At 9:14 PM, Blogger ShiftHappens 11:11 said...

Didn't work for me. Maybe because I didn't move the file to the 'backup folder' (wherever that is) HEEEEELP!

 
At 5:24 AM, Anonymous Anonymous said...

please give more detailed instructions ! thank you

 
At 12:00 PM, Blogger Kevin said...

This fix worked fantastically. How did you find out to do this?

 
At 7:11 AM, Anonymous Anonymous said...

Could you please explain what folder you're referring to when you're talking about "the backup folder"? More detailed information would be appreciated, thanks!

 
At 10:16 AM, Blogger Kevin said...

Anonymous, the backup folder referred to in his post is created by the batch file itself. You do not have to do anything but create the .bat file and run it for the process to work its "magic".

I found that after I ran the batch file, I had to reboot and manually search for drivers again, but this time the OS picked them up and installed successfully.

 
At 1:51 PM, Anonymous Anonymous said...

Many thanks for this incredibly useful nugget of info, i've passed on the link so hopefully more peeps can make use of it. Thanks agains

 
At 12:29 PM, Blogger Wulf said...

BIGG thanks, you saved me alot of work.

Thanks!!

 
At 6:07 AM, Anonymous Anonymous said...

Guys how do you give "Administrators" full control over the files? and the other bit about administrators?
Cheers

 
At 5:03 PM, Blogger Pete @ Eyes on Power said...

Thanks so much for this. You have just saved me a lot of time. If only Google had have found you quicker! Works perfectly. I don't need to wipe my machine now.

 
At 2:22 PM, Anonymous Anonymous said...

i know this is quite a bit later, but i used this a couple months ago and it worked, but just recently a vista update (either (KB938371)or (KB890830)) and this causes my computer to turn of fine,and i can still access its files through my network, but as soon as the update came i could not use any usb devices at all anywhere, so i had to restore with a recovery, the only culprate i can think of was this mod, as ive done no other changes to my os, i was just wondering if this has happend to you or anyone else that has used this,

rob, rechik97@hotmail.com

 
At 2:33 AM, Anonymous Anonymous said...

THANKS so much! like allen i've been struggling to solve my vista-mouse problem for days. Your solution is so easy. What i did:
1. create the batch file, just name it anything with .bat and i saved it on my desktop.
2. right click and run it as administrator
3. reboot
4. with PS/2 mouse, it will immediately work. for USB might need to manualy search for drivers again.

 
At 12:02 PM, Anonymous Anonymous said...

Woohoo, finally this works. Thank you so fucking much =).
I love ya!

 
At 11:09 PM, Anonymous Anonymous said...

Thanks so much i had the same problem when trying to plug in any device i had, but now it all works. THANKS SOO MUCH

 
At 2:07 PM, Anonymous Anonymous said...

Finally Someone with a little Brains!! Thanks for the fix!!

 
At 12:30 AM, Anonymous Anonymous said...

What about fixing the same issue in XP?

 
At 10:54 PM, Blogger darryl said...

simply genius

 
At 12:26 AM, Anonymous Anonymous said...

Awesome! Thanks!

 
At 1:19 PM, Anonymous Anonymous said...

I tried this script on Vista SP1 and it really screwed up my computer. Now no drivers will load. It says "Windows found driver software for your device but encountered an error while attempting to install it". "The system cannot find the file specified". Now none of the built-in Windows drivers can install. Restoring the backups doesn't work either, and SFC /scannow can't fix it. Unfortunately, I changed hard drivers recently and didn't realize my System Restore isn't working, so now my PC is royally screwed.

 
At 1:25 AM, Anonymous Anonymous said...

This helped me a lot too! Although I had to do one more step,

Point the Update Driver wizard to:
c:\Windows\System32\DriverStore\FileRepository\

 
At 4:03 PM, Anonymous Anonymous said...

Thank you very much! been having this problem a long time now... it´s the first time i can transfer more than 3 albuns to my jump drive...

 
At 11:35 AM, Blogger André said...

Nothing has worked for me so far...

Anyone has another solution?

 
At 4:21 PM, Anonymous Anonymous said...

OMG--you just ended a 48 hour nightmare! My problem was much deeper--I couldn't boot into my other operating system because the driver cache entry for "generic volume" became corrupt, and Vista wouldn't allow me to mount and fix that drive...and it wouldn't even let me manually point it to the inf. I was about to delete the other partition and start from scratch...BUT NO LONGER! THANK YOU!

 
At 2:25 PM, Anonymous Anonymous said...

Thanks!

have a PC running Vista with SP1 which had problems with a Netgear WG111T USB WiFi adaptor, the Netgear utility wouldn't run and there were occasional blue screens, typically when trying to hibernate the system, reporting an error in WG11TND5.SYS. Attempts to re-install the driver gave an error along the lines of "name is already in use as either a service name or a service display name".

Booting in safe mode, deleting all "netgear" and WG11* references and folders on the system didn't help.

Running the batch file did ... as I was then able to re-install the software and the driver, it is now working perfectly (including hibernate) - so a big pat on the back - and it works fine on Vista SP1 for me!!! :-)

Dan SJK

 
At 1:42 AM, Anonymous Anonymous said...

Thank you very much Peter, you saved my life.

After rebooting my laptop due to the unresponsiveness of Vista, I lost the connection to wireless keyboard and mouse. I spend a day to look for a solution from Microsoft support site and numerous technical pages without any success. Your batch file and a reboot fixed it for me.

I cannot believe that something discovered in 2007 is still causing trouble and there is no solution from Microsoft.
Damn you Microsoft, Damn you Vista.

Cheers,
Tevfik

 
At 6:20 PM, Blogger Unknown said...

Sorry, how do you do the following action (the one Henson mentioned):

Point the Update Driver wizard to:
c:\Windows\System32\DriverStore\FileRepository\

thanks,
Jaime

 
At 3:58 PM, Anonymous Anonymous said...

Oh my goodness, that's amazing.

THANK YOU!!

 
At 2:02 AM, Anonymous Anonymous said...

i saxed this bat file for future. but i accidenlty ran it. Now NONE of my usb drivers are uptodate and i cannot find updates for them. YES i tried manually to update no use and i tried to find online no use so far. Perhaps you could firect us as to where the backup file is. My sys back up was on a HDD but of course NONE of the usb devices work. And i recommended this to many friends in a forum. THANK GOD i listed your site so you could get the credit. Unfortunately the restoe point i could have used was auto deleted by vista i understand this is an old blog and useful for many so it prolly works well but i had a glitch and do not know fow to fix unless i do a total recovery, Please advise

 
At 3:16 PM, Blogger twenty8eight said...

I was minutes away from re-installing Vista from scratch....thanks so much for this, worked like a charm...

 
At 2:12 AM, Blogger John said...

I haven't been able to use a flash drive for months and it has been such a pain! thanks!

 
At 12:38 PM, Anonymous Anonymous said...

You are the man. EVERY morning, I would have to go through the process of reinstalling my video driver.

 
At 12:29 AM, Anonymous Anonymous said...

I was unable to update my Intel Matrix drivers, and my Blackberry and Garmin GPS unit would also fail at the driver installation. I created the batch file, rebooted my PC and ran it. Sure enough, this resolved the issue. THANK YOU!!! BTW, I'm running Vista 64bit with SP2

 
At 2:59 AM, Anonymous Anonymous said...

Wow.... after dealing with the hardware wizard popping up every time I plug in a device for a few months, it finally got the point where I couldn't deal with it any longer. I couldn't use my wacom tablet for a project, even after reinstalling the driver.

This totally saved me, thanks!

 
At 10:35 PM, Anonymous Anonymous said...

I'm still a little confused. I saved the file as a .bat and ran the program and then I restarted the computer but my USB mouse still doesn't work.

Can you explain in more detail or have a video explanation somewhere? It's a pain not being able to use my Logitech mouse anymore and I hate using the touchpad.

 
At 11:51 PM, Anonymous Anonymous said...

This worked, fixed my mouse problems with my new laptop in seconds after I had previously spent hours tinkering around with the settings. Thanks so much for your help!

 
At 11:59 PM, Anonymous Anonymous said...

Thanks a mil... now all my usb devices worked flawlessly except my external HDD which worked when i pointed vista to the filerepository folder and it installed ok!

Now i know why people hated vista so much when PnP means plug and pray ;)

 
At 3:30 PM, Anonymous Anonymous said...

Thank you sooo much!

I was really loosing my rag!

Bat file worked a charm, and i can finally stop having to use my iphone as a mouse!

14/12/09

 
At 9:37 PM, Anonymous Anonymous said...

Unfortunately, It did not help. I have the sme problem and still looking for the solution.

 
At 11:53 AM, Anonymous Sandra said...

Worked like a charm! Now I can actually use my brand new Sweex mouse on my Vaio running Vista Home Premium. Spent days trying to fix this before I found this post.

Thanks!

 
At 12:36 PM, Blogger Ambious said...

I'm actually surprised at how well this worked. Kudos!

 
At 7:32 AM, Anonymous Anonymous said...

I'm a pretty dumb guy, but, how do I create a .bat file? I'm not really a computer guy but this issue just happened to me recently and I'm pretty excited for this one to work after all the positive feedback from other people. Your help would be very much appreciated, thanks (:

 
At 12:32 AM, Anonymous Mathieu M-G said...

Saved my life! Thanks!!!

 
At 3:10 PM, Anonymous Anonymous said...

Hey! It really works! Thanks to author and big-big respect!

 
At 3:05 PM, Anonymous Tim said...

I might be the only person here who actually deleted his own driver cache based on a article I read with tips on conserving space with Vista. Needless to say, any new device (USB flash drive) or changes to a current device (flashed my dvd-rom burner bios) and it keeps asking for drivers and never finding them. For months.

Then I won the google guess the right key word (vista driver cache) and found this and it worked immediately.

Thank you Peter!

 
At 5:24 AM, Anonymous Anonymous said...

great! this patch solved my problem!!
USB mouse is working

 
At 2:19 AM, Blogger Jurassic Garden said...

Thank you, thank you, thank you. On August 9, 2011 this fix still works!

 
At 12:35 PM, Anonymous Electron said...

Peter - a HUGE thank you. I'm an IT 'expert' but I couldn't fix this problem, have been trying on and off for days! Within a few moments of reading your post my friend's PC could use it's USB ports again.
Many, many thanks

 
At 1:55 PM, Blogger Brianna said...

Todays date is 10-30-11 and the file worked for me. I bought a logitech USB wireless mouse and it didnt work upon plug in the USB adaptor.

I created the .BAT file in microsoft notepad, copied the next from above, saved it on my deskptop, right clicked and ran as administrator. The black window oppoed up stated it successfully relocated files. I then re-plugged in the USB connection and the mouse worked after about 10 seconds.

Im running MS Windows Vista Home Premium Service Pack 2.

THANKS!!!

 
At 7:55 AM, Anonymous Anonymous said...

Thank you, made my day. ;)

 
At 1:52 PM, Anonymous Anonymous said...

Am I missing something?
The explanation makes no sense.
Yes, I can it and yes I see a folder in /windows/inf but the next part makes absolutely no sense.

Move what to what backup area?
Do i move that folder to somewhere, do I move the inf/ files into it? What am I doing next?

You're explanation is flawed and I'm really struggling to understand how everyone else worked that part out.

 
At 10:40 AM, Anonymous Anonymous said...

I am confused as well about what to do!

 
At 3:18 AM, Anonymous Hank hendricks said...

The info is new for me..I like this..thanks for sharing.

Church Software

 
At 10:50 PM, Blogger Flash Drive Repair said...

good blog really , please can you give me your opinion in my blog
http://flashdrive-repair.blogspot.com

 
At 2:58 AM, Blogger Unknown said...

thanks to this i have issue on start-up my windows 7 , it is like freezing to long , but now it start not too long like before doing this.. thanks for sharing and teaching this programs..
is it okey if i forgot to buck up the original folder..

 
At 7:12 PM, Anonymous Anonymous said...

This is incredible! After praying, I was led to this post. I had been tearing out my hair installing a printer on this VISTA machine, and now it installed perfectly! To God be the glory (and you get some props too :-)

 

Post a Comment

<< Home