[wix-users] How do I uninstall a driver?

Jon Earle earlej at hotmail.com
Mon May 30 07:57:26 PDT 2016


I am having a lot of trouble uninstalling a driver. I have been following the examples on the 'net as best as I can understand them and I can get the driver installed.  The problem is with uninstallation - they don't.

Here is the relevant section of the product.wxs:

<Directory Id="MYDRIVER" Name="myDriver">
    <!-- Windows 7 -->
    <Component Id="myDriver_Win7" Guid="..." KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)">
        <Condition>VersionNT = 601</Condition>
        <File Id="myDriver.inf_win7" Name="myDriver.inf" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\Win7Release\myDriver.inf" />
        <File Id="myDriver.sys_win7" Name="myDriver.sys" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\Win7Release\myDriver.sys" />
        <File Id="myDriver_.cat_win7" Name="myDriver_.cat" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\Win7Release\myDriver_.cat" />
        <Driver AddRemovePrograms="no" DeleteFiles="yes" Legacy="yes" PlugAndPlayPrompt="no" Sequence="4" xmlns="http://schemas.microsoft.com/wix/DifxAppExtension" />
    </Component>
    <!-- Windows 8.1, Server 2012R2 -->
    <Component Id="myDriver_Win8.1" Guid="..." KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)">
        <Condition>VersionNT = 603</Condition>
        <File Id="myDriver.inf_win8.1" Name="myDriver.inf" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\Win8.1Release\myDriver.inf" />
        <File Id="myDriver.sys_win8.1" Name="myDriver.sys" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\Win8.1Release\myDriver.sys" />
        <File Id="myDriver_.cat_win8.1" Name="myDriver_.cat" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\Win8.1Release\myDriver_.cat" />
        <Driver AddRemovePrograms="no" DeleteFiles="yes" Legacy="yes" PlugAndPlayPrompt="no" Sequence="4" xmlns="http://schemas.microsoft.com/wix/DifxAppExtension" />
    </Component>
</Directory>

<Feature Id="extDevice" AllowAdvertise="no" ConfigurableDirectory="INSTALLDIR" Level="101" Title="External USB Device">
...
<ComponentRef Id="myDriver_Win7" />
<ComponentRef Id="myDriver_Win8.1" />
...
</Feature>

Which installs the appropriate driver, depending on OS version.  Uninstall, I would have thought, simply does the reverse.

I understand from reading https://msdn.microsoft.com/en-us/library/windows/hardware/ff553591%28v=vs.85%29.aspx , that DeleteFiles now does nothing (for OS's > win7). 

>From a bygone era, we also had a custom action (ported from installshield), which attempted to remove stale versions of the driver.  Code from prodict.wxs which sets up the custom action:

<CustomAction Id="CA_DeleteDriverSysFile" BinaryKey="CustomActions_dll" DllEntry="DeleteDriverSysFile" />

<InstallExecuteSequence>
...
<Custom Action="CA_DeleteDriverSysFile" After="RemoveFolders">(REMOVE="ALL") Or (feature selection conditions)</Custom>
...
</InstallExecuteSequence>

And the C# code:

[CustomAction]
public static ActionResult DeleteDriverSysFile(Session session)
{
    return DoDeleteDriverSysFile(session, MYDRIVER_SYS);
}

static ActionResult DoDeleteDriverSysFile(Session session, string driverFilen)
{
    try
    {
        string driverPath = Path.Combine(new string[] { Environment.SystemDirectory, "drivers", driverFilen });
        File.Delete(driverPath);
        return ActionResult.Success;
    }
    catch (Exception e)
    {
        return ActionResult.Failure;
    }
}

Pretty simple, but, the ActionResult.Failure code is always returned.. cannot delete the file from the drivers directory, even logged in as administrator.

What am I doing wrong here and what should I do so that the driver is removed?

How do I fix a windows server 2016 box that has this driver installed and where the uninstall now fails?

Cheers and thank you!
Jon

 		 	   		  


More information about the wix-users mailing list