Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shortcut #643

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions functions/public/Invoke-WPFButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function Invoke-WPFButton {
"WPFFixesUpdate" {Invoke-WPFFixesUpdate}
"WPFUpdatesdisable" {Invoke-WPFUpdatesdisable}
"WPFUpdatessecurity" {Invoke-WPFUpdatessecurity}


"WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil"}
}
}
33 changes: 33 additions & 0 deletions functions/public/Invoke-WPFShortcut.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function Invoke-WPFShortcut {
<#

.DESCRIPTION
Creates a shortcut

#>
param($ShortcutToAdd)

Switch ($ShortcutToAdd) {
"WinUtil" {
$SourceExe = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$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()

Write-Host "Shortcut for $ShortcutToAdd has been saved to $($FileBrowser.FileName)"
}
2 changes: 2 additions & 0 deletions xaml/inputXML.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@
<Label Content="Performance Plans" />
<Button Name="AddUltPerf" Background="AliceBlue" Content="Add Ultimate Performance Profile" HorizontalAlignment = "Left" Margin="5,0" Padding="20,5" Width="300"/>
<Button Name="RemoveUltPerf" Background="AliceBlue" Content="Remove Ultimate Performance Profile" HorizontalAlignment = "Left" Margin="5,0,0,5" Padding="20,5" Width="300"/>
<Label Content="Shortcuts" />
<Button Name="WinUtilShortcut" Background="AliceBlue" Content="Create WinUtil Shortcut" HorizontalAlignment = "Left" Margin="5,0" Padding="20,5" Width="300"/>

</StackPanel>
<StackPanel Background="#777777" SnapsToDevicePixels="True" Grid.Row="1" Grid.Column="1" Margin="10,5">
Expand Down