AveYo / fox

Firefox stuff
674 stars 66 forks source link

Convert Edge_Removal to pure PowerShell code #23

Closed SamHills closed 12 months ago

SamHills commented 1 year ago

There are several ways that Edge_Removal can be sped up by converting it to pure PowerShell code instead of calling cmd.exe to call other programs to do things that PowerShell can do much faster using its own built-in cmdlets.

It looks like the program was originally written as a batch file and only partially converted to PowerShell. Some of the issues that need to be addressed:

  1. Instead of CMD /C REG ADD, use Set-ItemProperty.
  2. Instead of CMD /C REG DELETE, use Remove-ItemProperty.
  3. Instead of CMD /C dism /online, call the PowerShell cmdlet directly.
  4. Instead of using SET to edit strings, just use PowerShell's built-in string-editing cmdlets and functions.
  5. Convert Edge_Removal.bat to a .ps1 file, move the "run as administrator" code to the top. and test whether or not the program already has administrator privilege before spawning a new PowerShell window.
AveYo commented 12 months ago

There are some quirks with powershell even now, so for simplicity it's a hybrid.
There's no meaningful speed difference, but sure, it can be improved upon at least for visual consistency