2023-05-09 13:14:27 -05:00
|
|
|
function Invoke-WPFShortcut {
|
|
|
|
<#
|
|
|
|
|
2023-10-19 17:12:55 -05:00
|
|
|
.SYNOPSIS
|
|
|
|
Creates a shortcut and prompts for a save location
|
|
|
|
|
|
|
|
.PARAMETER ShortcutToAdd
|
|
|
|
The name of the shortcut to add
|
2023-05-09 13:14:27 -05:00
|
|
|
|
|
|
|
#>
|
|
|
|
param($ShortcutToAdd)
|
|
|
|
|
|
|
|
Switch ($ShortcutToAdd) {
|
|
|
|
"WinUtil" {
|
2023-10-19 17:12:55 -05:00
|
|
|
$SourceExe = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
|
2023-05-09 13:14:27 -05:00
|
|
|
$IRM = 'irm https://christitus.com/win | iex'
|
|
|
|
$Powershell = '-ExecutionPolicy Bypass -Command "Start-Process powershell.exe -verb runas -ArgumentList'
|
|
|
|
$ArgumentsToSourceExe = "$powershell '$IRM'"
|
|
|
|
$DestinationName = "WinUtil.lnk"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$FileBrowser = New-Object System.Windows.Forms.SaveFileDialog
|
|
|
|
$FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop')
|
|
|
|
$FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk"
|
|
|
|
$FileBrowser.FileName = $DestinationName
|
|
|
|
$FileBrowser.ShowDialog() | Out-Null
|
|
|
|
|
|
|
|
$WshShell = New-Object -comObject WScript.Shell
|
|
|
|
$Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName)
|
|
|
|
$Shortcut.TargetPath = $SourceExe
|
|
|
|
$Shortcut.Arguments = $ArgumentsToSourceExe
|
|
|
|
$Shortcut.Save()
|
2023-10-19 17:12:55 -05:00
|
|
|
|
2023-05-09 13:14:27 -05:00
|
|
|
Write-Host "Shortcut for $ShortcutToAdd has been saved to $($FileBrowser.FileName)"
|
|
|
|
}
|