diff --git a/config/tweaks.json b/config/tweaks.json index 2a6bf95e..93ed630c 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -3464,14 +3464,5 @@ "Type": "Button", "ButtonWidth": "300", "link": "https://christitustech.github.io/winutil/dev/tweaks/Performance-Plans/RemoveUltPerf" - }, - "WPFWinUtilShortcut": { - "Content": "Create WinUtil Shortcut", - "category": "Shortcuts", - "panel": "2", - "Order": "a082_", - "Type": "Button", - "ButtonWidth": "300", - "link": "https://christitustech.github.io/winutil/dev/tweaks/Shortcuts/Shortcut" } } diff --git a/docs/dev/tweaks/Essential-Tweaks/DisableRecall.md b/docs/dev/tweaks/Essential-Tweaks/DisableRecall.md index 6635a7dc..a6ceaa73 100644 --- a/docs/dev/tweaks/Essential-Tweaks/DisableRecall.md +++ b/docs/dev/tweaks/Essential-Tweaks/DisableRecall.md @@ -36,7 +36,7 @@ Disables MS Recall built into Windows since 24H2. "InvokeScript": [ " Write-Host \"Disable Recall\" - DISM /Online /Disable-Feature /FeatureName:Recall + DISM /Online /Disable-Feature /FeatureName:Recall " ], "UndoScript": [ @@ -45,7 +45,7 @@ Disables MS Recall built into Windows since 24H2. DISM /Online /Enable-Feature /FeatureName:Recall " ], - "link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/DisableRecall" + "link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/DisableRecall" }, ``` @@ -56,7 +56,7 @@ Disables MS Recall built into Windows since 24H2. ```powershell Write-Host "Disable Recall" - DISM /Online /Disable-Feature /FeatureName:Recall + DISM /Online /Disable-Feature /FeatureName:Recall ``` diff --git a/docs/dev/tweaks/Shortcuts/Shortcut.md b/docs/dev/tweaks/Shortcuts/Shortcut.md index c980269e..e1776a30 100644 --- a/docs/dev/tweaks/Shortcuts/Shortcut.md +++ b/docs/dev/tweaks/Shortcuts/Shortcut.md @@ -27,87 +27,3 @@ Last Updated: 2024-08-07 ``` - -## Function: Invoke-WPFShortcut - -```powershell -function Invoke-WPFShortcut { - <# - - .SYNOPSIS - Creates a shortcut and prompts for a save location - - .PARAMETER ShortcutToAdd - The name of the shortcut to add - - .PARAMETER RunAsAdmin - A boolean value to make 'Run as administrator' property on (true) or off (false), defaults to off - - #> - param( - $ShortcutToAdd, - [bool]$RunAsAdmin = $false - ) - - # Preper the Shortcut Fields and add an a Custom Icon if it's available, else don't add a Custom Icon. - - Switch ($ShortcutToAdd) { - "WinUtil" { - # Use Powershell 7 if installed and fallback to PS5 if not - if (Get-Command "pwsh" -ErrorAction SilentlyContinue) { - $shell = "pwsh.exe" - } else { - $shell = "powershell.exe" - } - - $shellArgs = "-ExecutionPolicy Bypass -Command `"Start-Process $shell -verb runas -ArgumentList `'-Command `"irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1 | iex`"`'" - - $DestinationName = "WinUtil.lnk" - } - } - - # Show a File Dialog Browser, to let the User choose the Name and Location of where to save the Shortcut - $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog - $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop') - $FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk" - $FileBrowser.FileName = $DestinationName - - # Do an Early Return if the Save Operation was canceled by User's Input. - $FileBrowserResult = $FileBrowser.ShowDialog() - $DialogResultEnum = New-Object System.Windows.Forms.DialogResult - if (-not ($FileBrowserResult -eq $DialogResultEnum::OK)) { - return - } - - # Prepare the Shortcut paramter - $WshShell = New-Object -comObject WScript.Shell - $Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName) - $Shortcut.TargetPath = $shell - $Shortcut.Arguments = $shellArgs - if (Test-Path -Path $winutildir["logo.ico"]) { - $shortcut.IconLocation = $winutildir["logo.ico"] - } - - # Save the Shortcut to disk - $Shortcut.Save() - - if ($RunAsAdmin -eq $true) { - $bytes = [System.IO.File]::ReadAllBytes($FileBrowser.FileName) - # Set byte value at position 0x15 in hex, or 21 in decimal, from the value 0x00 to 0x20 in hex - $bytes[0x15] = $bytes[0x15] -bor 0x20 - [System.IO.File]::WriteAllBytes($FileBrowser.FileName, $bytes) - } - - Write-Host "Shortcut for $ShortcutToAdd has been saved to $($FileBrowser.FileName) with 'Run as administrator' set to $RunAsAdmin" -} - -``` - - - - - - - -[View the JSON file](https://github.com/ChrisTitusTech/winutil/tree/main/config/tweaks.json) - diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index ee4d0421..6473f693 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -50,7 +50,6 @@ function Invoke-WPFButton { "WPFFixesNetwork" {Invoke-WPFFixesNetwork} "WPFUpdatesdisable" {Invoke-WPFUpdatesdisable} "WPFUpdatessecurity" {Invoke-WPFUpdatessecurity} - "WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil" -RunAsAdmin $true} "WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"} "WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"} "WPFGetIso" {Invoke-WPFGetIso} diff --git a/functions/public/Invoke-WPFShortcut.ps1 b/functions/public/Invoke-WPFShortcut.ps1 deleted file mode 100644 index 9f5d379f..00000000 --- a/functions/public/Invoke-WPFShortcut.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -function Invoke-WPFShortcut { - <# - - .SYNOPSIS - Creates a shortcut and prompts for a save location - - .PARAMETER ShortcutToAdd - The name of the shortcut to add - - .PARAMETER RunAsAdmin - A boolean value to make 'Run as administrator' property on (true) or off (false), defaults to off - - #> - param( - $ShortcutToAdd, - [bool]$RunAsAdmin = $false - ) - - # Preper the Shortcut Fields and add an a Custom Icon if it's available, else don't add a Custom Icon. - - Switch ($ShortcutToAdd) { - "WinUtil" { - # Use Powershell 7 if installed and fallback to PS5 if not - if (Get-Command "pwsh" -ErrorAction SilentlyContinue) { - $shell = "pwsh.exe" - } else { - $shell = "powershell.exe" - } - - $shellArgs = "-ExecutionPolicy Bypass -Command `"Start-Process $shell -verb runas -ArgumentList `'-Command `"irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1 | iex`"`'" - - $DestinationName = "WinUtil.lnk" - } - } - - # Show a File Dialog Browser, to let the User choose the Name and Location of where to save the Shortcut - $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog - $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop') - $FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk" - $FileBrowser.FileName = $DestinationName - - # Do an Early Return if the Save Operation was canceled by User's Input. - $FileBrowserResult = $FileBrowser.ShowDialog() - $DialogResultEnum = New-Object System.Windows.Forms.DialogResult - if (-not ($FileBrowserResult -eq $DialogResultEnum::OK)) { - return - } - - # Prepare the Shortcut paramter - $WshShell = New-Object -comObject WScript.Shell - $Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName) - $Shortcut.TargetPath = $shell - $Shortcut.Arguments = $shellArgs - if (-NOT (Test-Path -Path $winutildir["logo.ico"])) { - Invoke-WebRequest -Uri "https://christitus.com/images/logo-full.ico" -OutFile $winutildir["logo.ico"] - } - if (Test-Path -Path $winutildir["logo.ico"]) { - $shortcut.IconLocation = $winutildir["logo.ico"] - } - - # Save the Shortcut to disk - $Shortcut.Save() - - Write-Host "Shortcut for $ShortcutToAdd has been saved to $($FileBrowser.FileName) with 'Run as administrator' set to $RunAsAdmin" -}