mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-17 18:27:42 -06:00
Compile Winutil
This commit is contained in:
parent
f5f506b9c5
commit
94abf3fd66
38
winutil.ps1
38
winutil.ps1
@ -10,7 +10,7 @@
|
|||||||
Author : Chris Titus @christitustech
|
Author : Chris Titus @christitustech
|
||||||
Runspace Author: @DeveloperDurp
|
Runspace Author: @DeveloperDurp
|
||||||
GitHub : https://github.com/ChrisTitusTech
|
GitHub : https://github.com/ChrisTitusTech
|
||||||
Version : 24.04.25
|
Version : 24.05.01
|
||||||
#>
|
#>
|
||||||
param (
|
param (
|
||||||
[switch]$Debug,
|
[switch]$Debug,
|
||||||
@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms
|
|||||||
# Variable to sync between runspaces
|
# Variable to sync between runspaces
|
||||||
$sync = [Hashtable]::Synchronized(@{})
|
$sync = [Hashtable]::Synchronized(@{})
|
||||||
$sync.PSScriptRoot = $PSScriptRoot
|
$sync.PSScriptRoot = $PSScriptRoot
|
||||||
$sync.version = "24.04.25"
|
$sync.version = "24.05.01"
|
||||||
$sync.configs = @{}
|
$sync.configs = @{}
|
||||||
$sync.ProcessRunning = $false
|
$sync.ProcessRunning = $false
|
||||||
|
|
||||||
@ -4342,27 +4342,35 @@ function Invoke-WPFShortcut {
|
|||||||
[bool]$RunAsAdmin = $false
|
[bool]$RunAsAdmin = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
$iconPath = $null
|
# Preper the Shortcut Fields and add an a Custom Icon if it's available at "$env:TEMP\cttlogo.png", else don't add a Custom Icon.
|
||||||
Switch ($ShortcutToAdd) {
|
$iconPath = $null
|
||||||
"WinUtil" {
|
Switch ($ShortcutToAdd) {
|
||||||
$SourceExe = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
|
"WinUtil" {
|
||||||
$IRM = 'irm https://christitus.com/win | iex'
|
$SourceExe = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||||
$Powershell = '-ExecutionPolicy Bypass -Command "Start-Process powershell.exe -verb runas -ArgumentList'
|
$IRM = 'irm https://christitus.com/win | iex'
|
||||||
$ArgumentsToSourceExe = "$powershell '$IRM'"
|
$Powershell = '-ExecutionPolicy Bypass -Command "Start-Process powershell.exe -verb runas -ArgumentList'
|
||||||
$DestinationName = "WinUtil.lnk"
|
$ArgumentsToSourceExe = "$powershell '$IRM'"
|
||||||
|
$DestinationName = "WinUtil.lnk"
|
||||||
|
|
||||||
if (Test-Path -Path "$env:TEMP\cttlogo.png") {
|
if (Test-Path -Path "$env:TEMP\cttlogo.png") {
|
||||||
$iconPath = "$env:SystempRoot\cttlogo.ico"
|
$iconPath = "$env:SystempRoot\cttlogo.ico"
|
||||||
ConvertTo-Icon -bitmapPath "$env:TEMP\cttlogo.png" -iconPath $iconPath
|
ConvertTo-Icon -bitmapPath "$env:TEMP\cttlogo.png" -iconPath $iconPath
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 = New-Object System.Windows.Forms.SaveFileDialog
|
||||||
$FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop')
|
$FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop')
|
||||||
$FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk"
|
$FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk"
|
||||||
$FileBrowser.FileName = $DestinationName
|
$FileBrowser.FileName = $DestinationName
|
||||||
$FileBrowser.ShowDialog() | Out-Null
|
|
||||||
|
# Do an Early Return if The Save Shortcut operation was cancel by User's Input.
|
||||||
|
$FileBrowserResult = $FileBrowser.ShowDialog()
|
||||||
|
$DialogResultEnum = New-Object System.Windows.Forms.DialogResult
|
||||||
|
if (-not ($FileBrowserResult -eq $DialogResultEnum::OK)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
$WshShell = New-Object -comObject WScript.Shell
|
$WshShell = New-Object -comObject WScript.Shell
|
||||||
$Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName)
|
$Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName)
|
||||||
|
Loading…
Reference in New Issue
Block a user