winutil icon indicating copy to clipboard operation
winutil copied to clipboard

Error Attempting to Uninstall Microsoft Edge

Open runninghamster0 opened this issue 1 year ago • 13 comments

Hi, When trying to uninstall Microsoft Edge by checking the box in the Tweaks section and clicking the 'Run tweaks' button, the relevant script to uninstall Microsoft Edge doesn't seem to be executed.

To Reproduce Steps to reproduce the behavior:

  1. Go to Tweaks
  2. Check box for Remove Microsoft Edge
  3. Click on Run Tweaks button
  4. See error in Terminal

Expected behavior The script to uninstall Edge should be executed.

Screenshots image image image

runninghamster0 avatar May 10 '23 03:05 runninghamster0

same problem.
@DeveloperDurp I looked into code as far as i understand "InvokeScript" works fine for "WPFEssTweaksDiskCleanup", "WPFMiscTweaksRightClickMenu" but the problem occur in :

  • WPFEssTweaksRemoveCortana
  • WPFEssTweaksRemoveEdge

I changed the value of InvokeScript in WPFEssTweaksRemoveEdge for testing and it's work fine. i don't understand Invoke-WinUtilTweaks.ps1 and Invoke-WinUtilFeatureInstall.ps1 files but i think there is problem maybe.

padsalatushal avatar May 10 '23 09:05 padsalatushal

Both of those go through the invoke script function https://github.com/ChrisTitusTech/winutil/blob/main/functions/private/Invoke-WinUtilScript.ps1

you can replicate the issue by importing that function into your powershell session, create a scriptblock and pass it.

[scriptblock]$scriptblock = {Invoke-WebRequest -useb https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/Edge_Removal.bat | Invoke-Expression}

Invoke-WinUtilScript -name test -scriptblock $scriptblock

Think of Invoke-WinUtilTweaks as the gatekeeper to all the tweaks, all it's really doing is taking the checkboxes that were checked and if there is a matching value in the config it will then run the corresponding tweaks through a dedicated function.

DeveloperDurp avatar May 10 '23 11:05 DeveloperDurp

@DeveloperDurp I think i figure out the issue. the edge removal script is giving some errors like registry is not found and some others. and when some error happens script stops it's execution

    Try{
        Invoke-Command $scriptblock -ErrorAction stop
        Write-Host "Running Script for $name"
    }
    Catch{
        Write-Warning "Unable to run script for $name due to unhandled exception"
        Write-Warning $psitem.Exception.StackTrace 
    }
}

image I removed try and catch and run this function and it's work fine even the edge removal script gives some error but at the end script ran fine.

so to solve this issue is there any other way rather than removing try and catch from "Invoke-WinUtilScript" function .

padsalatushal avatar May 10 '23 13:05 padsalatushal

I realized the issue with WPFEssTweaksRemoveEdge, it's calling a batch file, we would need to change how it's ran in the config so that it pulls the file and runs it with cmd.exe instead of | iex. Though I think @ChrisTitusTech was thinking of removing this option to begin with.

For WPFEssTweaksRemoveCortana we can add another catch block for the specific error and handle it specifically instead of a generic catch. Similar to how I do it here. You should be able to get the exception by modifying the function and output the error into a variable. It would look something like this and $test will contain all the details about the error.

Try{
    Invoke-Command $scriptblock -ErrorAction stop
    Write-Host "Running Script for $name"
}
Catch{
    $test = $psitem
}

DeveloperDurp avatar May 10 '23 14:05 DeveloperDurp

    Try {
        Invoke-Command $scriptblock -ErrorAction Stop
        Write-Host "Running Script for $name"
    }
    Catch [System.Management.Automation.CommandNotFoundException] {
        Write-Warning "The specified command was not found."
        Write-Warning $PSItem.Exception.StackTrace
    }
    Catch [System.Management.Automation.RuntimeException] {
        Write-Warning "A runtime exception occurred."
        Write-Warning $PSItem.Exception.StackTrace
    }
    Catch [System.Security.SecurityException] {
        Write-Warning "A security exception occurred."
        Write-Warning $PSItem.Exception.StackTrace
    }
    Catch [System.UnauthorizedAccessException] {
        Write-Warning "Access denied. You do not have permission to perform this operation."
        Write-Warning $PSItem.Exception.StackTrace
    }
    Catch {
        # Generic catch block to handle any other type of exception
        Write-Warning "An unhandled exception occurred."
        Write-Warning $PSItem.Exception.StackTrace
    }
    

@DeveloperDurp take a look

padsalatushal avatar May 11 '23 02:05 padsalatushal

So far so good, I would avoid putting the stack trace inside exceptions that we are handling, it can cause confusion for the user if they get a huge wall of text. Though depending on the message I believe $psitem.exception.message can include useful information.

DeveloperDurp avatar May 11 '23 10:05 DeveloperDurp

@DeveloperDurp image

is UndoScript not working or i am doing something wrong. can you please explain how can I use UndoScript?

padsalatushal avatar May 13 '23 05:05 padsalatushal

Resolved in #750

padsalatushal avatar May 17 '23 03:05 padsalatushal

@padsalatushal Currently there is no undo script functions, could be implemented fairly easily as I skipped it to prioritize the registry, services and scheduled tasks.

you would only need to add the undoscript to the config file and modify this function https://github.com/ChrisTitusTech/winutil/blob/main/functions/private/Invoke-WinUtilTweaks.ps1

DeveloperDurp avatar May 17 '23 10:05 DeveloperDurp

@DeveloperDurp I get the config file part but can you explain more on https://github.com/ChrisTitusTech/winutil/blob/main/functions/private/Invoke-WinUtilTweaks.ps1 in this file what to modify and where to modify? sorry for this type of dump question.

padsalatushal avatar May 17 '23 13:05 padsalatushal

These lines execute the script blocks from the config file. Currently it will only run if the undo variable is false. You would need to move this out of that block.

https://github.com/ChrisTitusTech/winutil/blob/2c6b4598707b8f29c2bddf74bf92e52d5cf72380/functions/private/Invoke-WinUtilTweaks.ps1#L50-L54

From there you would need to modify the following lines so you can provide the correct scriptblock to the function based if the undo variable is true or false.

https://github.com/ChrisTitusTech/winutil/blob/2c6b4598707b8f29c2bddf74bf92e52d5cf72380/functions/private/Invoke-WinUtilTweaks.ps1#L13-L26

DeveloperDurp avatar May 19 '23 11:05 DeveloperDurp

going to tag @ChrisTitusTech as there is some decent information here that might help him as well.

DeveloperDurp avatar May 19 '23 11:05 DeveloperDurp

@runninghamster0 It is resolved in #750 you can close this issue.

padsalatushal avatar May 19 '23 12:05 padsalatushal

Currently unable to uninstall or remove Microsoft Edge because "Winget failed to install" despite installing in from the Microsoft Store. Is there a solution for installing Winget? (I'd rather not open a new issue unless absolutely necessary - tried installing winget through this link but to no avail: https://apps.microsoft.com/store/detail/app-installer/9NBLGGH4NNS1?hl=en-mt&gl=mt&rtc=1)

Thank you in advance.

image

brandleesee avatar May 28 '23 10:05 brandleesee

@brandleesee

for installing winget : open PowerShell as admin and run following commands:

Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Script -Name winget-install -Force
winget-install.ps1

padsalatushal avatar May 28 '23 13:05 padsalatushal

Thank you, @padsalatushal, had some hiccups but winget was installed successfully.

Re: the removal of Microsoft Edge, something seems amiss.

The install failed with the exit code 93.

Just in case, restarted the laptop and Edge functioned normally, i.e. not installed.

Any pointers on this, please? Thank you in advance.

image

brandleesee avatar May 28 '23 15:05 brandleesee

@brandleesee For removing edge go to the tweaks section and select "Remove Microsoft Edge" and click on Run Tweaks Button

padsalatushal avatar May 28 '23 15:05 padsalatushal

@padsalatushal, thank you for your help.

Initially, that is the procedure I adopted but because it was not successful, I opted to install chocolatey/winget and uninstall it from there since there are two options to remove Microsoft Edge (Winget uninstall selection Edge OR Tweaks Remove Microsoft Edge).

The below screen shows that Edge and Webview were removed, however, after restarting the computer, Edge was still visible in Start Menu and fully functional.

Anything else I can try, please?

image

brandleesee avatar May 28 '23 15:05 brandleesee

@brandleesee edge is usually come back after updating windows. can you try one more time and also tell me which windows version are you using? I tested remove edge features on multiple systems and it's work.

padsalatushal avatar May 28 '23 15:05 padsalatushal

Yes, sure!

From Tweaks Tab

Unsuccessful.

image

image

From Winget

Unsuccessful.

image

image

image

brandleesee avatar May 28 '23 16:05 brandleesee

Further to the above post, after restart, Microsoft Edge is still visible and fully functional.

Hardware specs follow:

https://kelaptop.com/en/acer-spin-1-sp111-31-c4av-nx-gl2ek-004

Basics: Acer Spin 1 SP111-31-C4AV Windows 10 Home

brandleesee avatar May 28 '23 16:05 brandleesee

@brandleesee I will work on this issue . For now, if you want to remove edge checkout: https://github.com/padsalatushal/Edge-Removal

padsalatushal avatar May 28 '23 16:05 padsalatushal

Thank you, @padsalatushal! Your batch script worked well, with some caveats. The entry in Microsoft Edge has remained. However, when I click on it, the browser does not start - which is good. Another thing I noticed is that the Edge install is still present on Windows. In any case, Edge no longer works now!

brandleesee avatar May 28 '23 16:05 brandleesee

Hi All, I'm really hoping that in the near future that it will be a lot easier to uninstall microsoft edge while using the one tool for everything utility software, of course I really feel like one of the major issues with trying to uninstall ms edge is how it's so intertwined within the operating system.

Davy49 avatar Jun 02 '23 12:06 Davy49

Thanks @padsalatushal I'm going to use your bat script Fixed in commit https://github.com/ChrisTitusTech/winutil/commit/b2e3def5116c391d84b47f6c38f108290ae833bd

ChrisTitusTech avatar Jul 20 '23 21:07 ChrisTitusTech