Batch file to delete .inf files from a ADMIN CMDprompt.
Moderator: DosItHelp
Batch file to delete .inf files from a ADMIN CMDprompt.
Hi guys s there a convenient way to create a batch file to delete these .inf (in my case graphic driver) files from my manual procedure listed below?
-Open ADMIN CMD prompt.
-Type: pnputil.exe -e (This shows all the .inf files from drivers installed)
-Type: pnputil.exe -d oem###.inf (The specific .inf file)
-Open ADMIN CMD prompt.
-Type: pnputil.exe -e (This shows all the .inf files from drivers installed)
-Type: pnputil.exe -d oem###.inf (The specific .inf file)
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
On my phone and I do not know what the output of the pnputil program looks like.
Code: Select all
for /f "delims=" %%G in ('pnputil -e') do pnputil -d %%G
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,* delims=:" %%i in (
'pnputil -e^|findstr /b /c:"Published name :"'
) do (
set "X=%%j"
pnputil.exe -d "!X: =!"
)
pause
This is untested because I am scared
Meerkat
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
WARNING, The responses so far would delete all drivers!
Since the OP stated graphics drivers, here is an English language based solution using the tool stated.
If you're happy with the solution, remove the five characters Echo= on line five and all of line six.
Since the OP stated graphics drivers, here is an English language based solution using the tool stated.
Code: Select all
@Echo Off
SetLocal
For /F "Tokens=1,3,4" %%A In ('PnPUtil -e') Do (
If "%%A" Equ "Published" Set "_=%%C"
If "%%B %%C" Equ "Display adapters" Call Echo=PnPUtil -d -f %%_%%)
Pause
If you're happy with the solution, remove the five characters Echo= on line five and all of line six.
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
Hi,
How can this script be adapted so that it deletes the driver oem##.inf package for the driver that contains 12/13/2016 1.0.0.2.
Manually this would be done like so:
-Open ADMIN CMD prompt.
-Type: pnputil.exe -e (This shows all the .inf files from drivers installed)
- Search through the list to identify the oem##.inf for the driver which has a driver date and version of 12/13/2016 1.0.0.2
-Type: pnputil.exe -f -d oem##.inf
How can this script be adapted so that it deletes the driver oem##.inf package for the driver that contains 12/13/2016 1.0.0.2.
Manually this would be done like so:
-Open ADMIN CMD prompt.
-Type: pnputil.exe -e (This shows all the .inf files from drivers installed)
- Search through the list to identify the oem##.inf for the driver which has a driver date and version of 12/13/2016 1.0.0.2
-Type: pnputil.exe -f -d oem##.inf
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
In the code of this answer:
Modify the core code in this way:
Antonio
- Change @echo %%b by set "driver=%%b"
- Insert pnputil.exe -f -d %driver% at end
Modify the core code in this way:
Code: Select all
pnputil -e > test.txt
findstr /R /C:".*!\n!.*!\n!.*!\n!.*%search%" test.txt > test2.txt
for /F "tokens=2 delims=:" %%a in (test2.txt) do for /F "tokens=*" %%b in ("%%a") do set "driver=%%b"
pnputil.exe -f -d %driver%
del test.txt test2.txt
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
Thank you Aacini. That works. Driver is found and then deleted.
I wanted to keep this code in my toolbox too from Compo, and apply it to smart card readers but it doesn't work any I don't know why. I expected it to delete all smart card reader drivers on the machine but it doesn't. Not sure where it is failing.
I wanted to keep this code in my toolbox too from Compo, and apply it to smart card readers but it doesn't work any I don't know why. I expected it to delete all smart card reader drivers on the machine but it doesn't. Not sure where it is failing.
Code: Select all
@Echo Off
SetLocal
For /F "Tokens=1,3,4" %%A In ('PnPUtil -e') Do (
If "%%A" Equ "Published" Set "_=%%C"
If "%%B %%C" Equ "Smart card readers" Call Echo=PnPUtil -d -f %%_%%)
Pause
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
Your code is just echoing to the screen what the pnputil execution would do.