Cannot uninstall network adapter through powershell script - Advanced Installer Community
amber
Posts: 1
Joined: Tue Jun 20, 2023 11:27 pm

Cannot uninstall network adapter through powershell script

Hello,

I am trying to remove tap driver through Custom action using powershell script. Script runs successfully when executing it directly, however it fails when it is executed through Custom action in installer.

Script:

Code: Select all

function removeTapDriver()
{
    $tapDriverName = "TAP Driver Windows"
    $tapDriver = Get-Package $tapDriverName
    if($tapDriver -ne $null)
    {
        Uninstall-Package -Name $tapDriverName -Force
    }
}

removeTapDriver
Configuration:
Execution stage: Remove resources
Execution time: When the system is being modified (deferred)
Execution options: Run under the LocalSystem account with full privileges (no impersonation)
Execution policy: Bypass
Scrip is run as admin

Output:

Code: Select all

Uninstall-Package : Uninstallation operation failed. Please look at 
'msi.log' file for details.
At scrD3C3.ps1:10 char:9
+         Uninstall-Package -Name $tapDriverName -Force
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({F4A3C37C-4D08-4D6F-AAEA-35980C773582}:String) [Uninstall-Package], E 
   xception
    + FullyQualifiedErrorId : Uninstallation operation failed. Please look at '{0}' file for details.,Microsoft.PowerS 
   hell.PackageManagement.Cmdlets.UninstallPackage
   
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Cannot uninstall network adapter through powershell script

Hello and welcome to our forums,

I'm not sure why this happens.

Have you checked the "msi.log" file for details?

Can you please send us the .AIP (setup project) file and an installation log by email to support at advancedinstaller dot com so we can further test and investigate this?

You can create an installation log by launching your setup package with a command line like this:

Code: Select all

msiexec /i setup.msi /L*V "C:\installLog.txt"
when using an MSI package type, or a command like this

Code: Select all

setup.exe /L*V "C:\installLog.txt"
when using an EXE package type.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”