pnputil
Uninstall via command line
If you want to uninstall the driver from the .INF file via the command line, you need to use the PnPUtil command. Here is an example:
pnputil /delete-driver oem0.inf /uninstall
In this example, oem0.inf
should be replaced with the .inf file of the driver you want to uninstall. Use pnputil /enum-drivers
the command to list the list of installed drivers.
Note that you need to be running a Command Prompt window as an administrator to do this.
Before using these methods, make sure to back up your data and know how to recover from the system (for example, if you uninstalled the wrong driver). These steps can cause problems if the system is unstable or unbootable.
Integrated into InnoSetUp:
[UninstallRun]
RunOnceId:"StopPS5Driver"; Filename:"{cmd}"; Parameters:"/C pnputil /delete-driver flydigigamemap.inf /uninstall > ""{app}\FlydigiUninstall.log"" 2>&1"; Flags:runhidden runascurrentuser
Summary: After this command was integrated into InnoSetUp, it was not successfully uninstalled in the end, and the reason was not found.
Devcon tool uninstall
If the above two points are confirmed but still can't be uninstalled, you may need to consider using a lower-level driver management tool, such as Devcon
(part of the Windows Driver Development Kit (WDK)).
Devcon
The tool provides a remove
command that can be used to uninstall devices and drivers. In this case, you need to know the hardware ID of the device. Here is Devcon
an example to uninstall a driver using:
[UninstallRun]
RunOnceId:"StopPS5Driver"; Filename:"{cmd}"; Parameters:"/C devcon remove @YourHardwareID > ""{app}\Uninstall.log"" 2>&1"; Flags:runhidden runascurrentuser
In this example, you should substitute YourHardwareID
the hardware ID of the device you want to uninstall.
Please note that devcon
it is not a standard part of the Windows operating system, so if you choose this method, you may need to include the devcon
executable file in your installation package, or download it in your uninstall script.
Finally, remember to be careful when handling drivers and devices, as incorrect handling can lead to system instability. Before performing any such operation, you should make sure you have backed up your important data.
when uninstalling an app
[UninstallRun]
RunOnceId:"StopPS5Driver"; Filename:"{cmd}"; Parameters:"/C pnputil /delete-driver @YOUInfFileName /uninstall > ""{app}\FlydigiUninstall.log"" 2>&1"; Flags:runhidden runascurrentuser
install the application
[Run]
Filename:"{app}\devcon.exe"; Parameters:"remove @YourHardwareID"; Flags:runhidden runascurrentuser; StatusMsg:"Removing old driver..."
Summary: This method perfectly solves the problem of driver uninstallation.