mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-29 01:11:30 -06:00
Compare commits
11 Commits
d20d192712
...
caf3f38077
Author | SHA1 | Date | |
---|---|---|---|
|
caf3f38077 | ||
|
77cb0a14c4 | ||
|
c254a43f77 | ||
|
640d2ca107 | ||
|
c186642998 | ||
|
47a4f1547e | ||
|
1caf3111d3 | ||
|
31be3b01c6 | ||
|
a9a6d7cf64 | ||
|
1bc32e0aff | ||
|
6a871b1feb |
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
||||
```
|
||||
|
@ -1,113 +0,0 @@
|
||||
# Create WinUtil Shortcut
|
||||
|
||||
Last Updated: 2024-08-07
|
||||
|
||||
|
||||
!!! info
|
||||
The Development Documentation is auto generated for every compilation of WinUtil, meaning a part of it will always stay up-to-date. **Developers do have the ability to add custom content, which won't be updated automatically.**
|
||||
|
||||
|
||||
<!-- BEGIN CUSTOM CONTENT -->
|
||||
|
||||
<!-- END CUSTOM CONTENT -->
|
||||
|
||||
<details>
|
||||
<summary>Preview Code</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"Content": "Create WinUtil Shortcut",
|
||||
"category": "Shortcuts",
|
||||
"panel": "2",
|
||||
"Order": "a082_",
|
||||
"Type": "Button",
|
||||
"ButtonWidth": "300",
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Shortcuts/Shortcut"
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 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"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
<!-- BEGIN SECOND CUSTOM CONTENT -->
|
||||
|
||||
<!-- END SECOND CUSTOM CONTENT -->
|
||||
|
||||
|
||||
[View the JSON file](https://github.com/ChrisTitusTech/winutil/tree/main/config/tweaks.json)
|
||||
|
@ -807,41 +807,6 @@ function New-FirstRun {
|
||||
Remove-Item -Path "$env:USERPROFILE\Desktop\*.lnk"
|
||||
Remove-Item -Path "$env:HOMEDRIVE\Users\Default\Desktop\*.lnk"
|
||||
|
||||
# ************************************************
|
||||
# Create WinUtil shortcut on the desktop
|
||||
#
|
||||
$desktopPath = "$($env:USERPROFILE)\Desktop"
|
||||
# Specify the target PowerShell command
|
||||
$command = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command 'irm https://christitus.com/win | iex'"
|
||||
# Specify the path for the shortcut
|
||||
$shortcutPath = Join-Path $desktopPath 'winutil.lnk'
|
||||
# Create a shell object
|
||||
$shell = New-Object -ComObject WScript.Shell
|
||||
|
||||
# Create a shortcut object
|
||||
$shortcut = $shell.CreateShortcut($shortcutPath)
|
||||
|
||||
if (Test-Path -Path "$env:HOMEDRIVE\Windows\cttlogo.png") {
|
||||
$shortcut.IconLocation = "$env:HOMEDRIVE\Windows\cttlogo.png"
|
||||
}
|
||||
|
||||
# Set properties of the shortcut
|
||||
$shortcut.TargetPath = "powershell.exe"
|
||||
$shortcut.Arguments = "-NoProfile -ExecutionPolicy Bypass -Command `"$command`""
|
||||
# Save the shortcut
|
||||
$shortcut.Save()
|
||||
|
||||
# Make the shortcut have 'Run as administrator' property on
|
||||
$bytes = [System.IO.File]::ReadAllBytes($shortcutPath)
|
||||
# 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($shortcutPath, $bytes)
|
||||
|
||||
Write-Host "Shortcut created at: $shortcutPath"
|
||||
#
|
||||
# Done create WinUtil shortcut on the desktop
|
||||
# ************************************************
|
||||
|
||||
try
|
||||
{
|
||||
if ((Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -like "Recall" }).Count -gt 0)
|
||||
|
@ -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}
|
||||
|
@ -1,72 +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()
|
||||
|
||||
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"
|
||||
}
|
@ -42,4 +42,24 @@ function Invoke-WPFUpdatesdefault {
|
||||
Write-Host "==================================================="
|
||||
Write-Host "--- Windows Update Settings Reset to Default ---"
|
||||
Write-Host "==================================================="
|
||||
|
||||
Start-Process -FilePath "secedit" -ArgumentList "/configure /cfg $env:windir\inf\defltbase.inf /db defltbase.sdb /verbose" -Wait
|
||||
Start-Process -FilePath "cmd.exe" -ArgumentList "/c RD /S /Q $env:WinDir\System32\GroupPolicyUsers" -Wait
|
||||
Start-Process -FilePath "cmd.exe" -ArgumentList "/c RD /S /Q $env:WinDir\System32\GroupPolicy" -Wait
|
||||
Start-Process -FilePath "gpupdate" -ArgumentList "/force" -Wait
|
||||
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKCU:\Software\Microsoft\WindowsSelfHost" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKCU:\Software\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\Microsoft\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\Microsoft\WindowsSelfHost" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "==================================================="
|
||||
Write-Host "--- Windows Local Policies Reset to Default ---"
|
||||
Write-Host "==================================================="
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
{{ super() }}
|
||||
<div style="color: red; text-align: center; padding: 10px; font-size: 20px;">
|
||||
<strong>Announcement:</strong> We are currently not adding any applications to WinUtil and any apps that will be added through a PR will be declined by the maintainer.
|
||||
<strong>Announcement:</strong> We are currently reworking the docs to use Hugo rather then mkdocs.
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -39,32 +39,26 @@ $sync.version = "#{replaceme}"
|
||||
$sync.configs = @{}
|
||||
$sync.ProcessRunning = $false
|
||||
|
||||
# Store latest script URL in variable.
|
||||
$latestScript = "https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1"
|
||||
|
||||
# Check if script is running as Administrator
|
||||
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
|
||||
$argList = @()
|
||||
|
||||
$PSBoundParameters.GetEnumerator() | ForEach-Object {
|
||||
$argList += if ($_.Value -is [switch] -and $_.Value) {
|
||||
"-$($_.Key)"
|
||||
} elseif ($_.Value) {
|
||||
"-$($_.Key) `"$($_.Value)`""
|
||||
}
|
||||
}
|
||||
|
||||
$script = if ($MyInvocation.MyCommand.Path) {
|
||||
"& { & '$($MyInvocation.MyCommand.Path)' $argList }"
|
||||
} else {
|
||||
"iex '& { $(irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1) } $argList'"
|
||||
}
|
||||
# Partial rollback from #2648, changed irm and iex to Invoke-RestMethod and Invoke-Expression.
|
||||
$script = if ($MyInvocation.MyCommand.Path) { "& '" + $MyInvocation.MyCommand.Path + "'" } else { "Invoke-RestMethod '$latestScript' | Invoke-Expression"}
|
||||
|
||||
$powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" }
|
||||
$processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { "wt.exe" } else { $powershellcmd }
|
||||
|
||||
# Start new process with elevated privileges
|
||||
Start-Process $processCmd -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -Command $script" -Verb RunAs
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
# Logging
|
||||
$dateTime = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
|
||||
$logdir = "$env:localappdata\winutil\logs"
|
||||
|
Loading…
Reference in New Issue
Block a user