I know pnputil.exe /enum-drivers
can do this, but how to do this by programmatically? Redirect the standard output of pnputil
seems very unprofessional.
what bigger problem are you trying to solve?
@Doron_Holan said:
what bigger problem are you trying to solve?
Suppose you install a driver package by DiInstallDriver
with the inf
at D:\MyDriver\MyDriver.inf
, but later the folder D:\MyDriver\
be deleted. How do you reliably delete MyDriver
from the Driver Store except enum the C:\Windows\System32\DriverStore\FileRepository
for searching something folder name starts with MyDriver
? Seaching folder starts with MyDriver
is for getting the inf
as the parameter of calling DiUninstallDriver
.
You can use SetupDiBuildDriverInfoList + SetupDiEnumDriverInfo to enumerate all the drivers
@Zac_Lockard said:
You can use SetupDiBuildDriverInfoList + SetupDiEnumDriverInfo to enumerate all the drivers
I had tried, it will not enumerate the WFP callout driver, which installed by both pnputil
or DiInstallDriver
.
There is nothing unprofessional about parsing the output of a known-good tool. That’s essentially the Unix philosophy.
Can’t you scan through C:\Windows\Inf\oem*.inf to find your INF file? That’s how I remove packages – by using the oem##.inf name.
@Tim_Roberts said:
There is nothing unprofessional about parsing the output of a known-good tool. That’s essentially the Unix philosophy.Can’t you scan through C:\Windows\Inf\oem*.inf to find your INF file? That’s how I remove packages – by using the oem##.inf name.
The pnputil
output was localized, it is difficult to guarantee accurate parsing on devices with different languages.
Scanning system directories always feels unreliable to me. I prefer to use a documented API if possible.
You’re right, but you’re talking about a development/testing operation here, right? Microsoft doesn’t really recommend deleting driver packages in a production environment.
@Tim_Roberts said:
You’re right, but you’re talking about a development/testing operation here, right? Microsoft doesn’t really recommend deleting driver packages in a production environment.
Sorry… I’m talking about deployment.
@iFengHuang said:
@Zac_Lockard said:
You can use SetupDiBuildDriverInfoList + SetupDiEnumDriverInfo to enumerate all the driversI had tried, it will not enumerate the WFP callout driver, which installed by both
pnputil
orDiInstallDriver
.
Ah, you’re right, that won’t enumerate any primitive drivers, we don’t have any API that will do this. If you were to enumerate the drivers in the directory, how would you know if you found a match? I’m curious what data you have available.
@Zac_Lockard said:
@iFengHuang said:
@Zac_Lockard said:
You can use SetupDiBuildDriverInfoList + SetupDiEnumDriverInfo to enumerate all the driversI had tried, it will not enumerate the WFP callout driver, which installed by both
pnputil
orDiInstallDriver
.Ah, you’re right, that won’t enumerate any primitive drivers, we don’t have any API that will do this. If you were to enumerate the drivers in the directory, how would you know if you found a match? I’m curious what data you have available.
Because I just try to remove my own driver, so I know the driver name. I just need to find out the folder begins with my driver name in C:\Windows\System32\DriverStore\FileRepository
, e.g. mydriver.inf_amd64_326d92dad12343245adf34
, the inf
file is in it, get the inf
full path, then pass to DiUninstallDrvier
, that’s all, the driver package will be removed cleanly.
Or, as I said, find your oem##.inf in C:\Windows\Inf. That can also be used to uninstall. Your driver registry keys include an entry that has your assigned INF name.