mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-15 15:15:51 -06:00
5e3c6ba452
* Compile Winutil * pre-Releases (#1) * Create pre-release.yaml * Update release.yaml * Update pre-release.yaml * Create release-drafter.yml * Update release-drafter.yml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update pre-release.yaml * Update release-drafter.yml * Update pre-release.yaml * Update release-drafter.yml * Update pre-release.yaml * Update release-drafter.yml * Update release-drafter.yml * Update pre-release.yaml * Update pre-release.yaml * Update release-drafter.yml * Update release-drafter.yml * Update release.yaml * Update release-drafter.yml * Update release-drafter.yml * Update pre-release.yaml * Compile Winutil * fixed end task with right click * Compile Winutil * code generator & compile integration * Compile Winutil * finish - add autogenerated table of content page named "Dev Docs", with table of content to all .md files - added invokescript & undoscript - generate documentation files * oops, remove dublicates * undo winutil.ps1 * remove prefixes WPF WinUtil Toggle $category Features Tweaks Panel Fixes * fixes - fix inconsistency in Featurenaming - add "Enable" & "Disable" as prefix to remove * fix spellin mistake * remove unneccesary whitespaces update info remove unnecessary whitespaces by only adding stuff to the md if it actually exists * rewrite prefix removal into one line definition * added taskscheduler support * add support for function calling add support for functioncalling - replace code formatting for invoke & undo script from json to powershell * content instead of displayname * add last modified date * contributing + docs generator - moved contribute.md to root CONTRIBUTING.md - referenced CONTRIBUTING.md in contribute.md - added toggle & button reference to functions - added function references in functions - changed mkdocs site styling * Use HashSet for processedFunctions Use HashSet for processedFunctions: - Ensures dynamic addition of functions without duplication. Recursive Function Scanning: - Includes all nested functions called by InvokeScript, UndoScript, ToggleScript, and ButtonScript. * follow github standards - add code of conduct - reference code of conduct in docs - regrouped docs navigation - add comment about the sourced md file * small fixes * change color from teal to blue in light mode * add links to tweaks * add archiving feature to autodocs * administrative - add script to releases and remove from compile - move link from after description to after category * small fixes - add S in feature.json - fix dating - move link to after category * fix links * undo link bc of bugs * add progress bar to script - add progress like in compile - moved archive folder creation to the beginning of the script * Simple improvements to 'auto-devdocs' branch (#3) * Fix links for tweaks & features * Make New Line characters work for Json Snippet * Change NewLine Character from Unix Style (LF) to Windows/DOS Style (CRLF) * rerun script * und workflows & rearrange navigation items * layer out itemname cutout * rework links & temp removal of archivation * fix adding link in json root not adding link member to root in json files * fix json generation replace '\r\n',"`r`n" with ('\n',"`n") * add features to auto md docs * add minify plugin * regex hotfix * refractor * add changelog to about section add link to changelog in docs for about section * undo changelog * Cleanup 'devdocs-generator.ps1' - Implement Zig Multiline String Feature (#4) * Cleanup 'devdocs-generator.ps1' - Implement Zig Multiline String Feature * Fix NewLine character replace in 'devdocs-generator.ps1' * run script * run script * Fix 'itemnametocut' RegEx in 'devdocs-generator.ps1' (#5) * rerun script * rework nav + remove code of conduct * undo workflow changes * run script * remove changelog --------- Co-authored-by: MyDrift-user <MyDrift-user@users.noreply.github.com> Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
3.4 KiB
3.4 KiB
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.
Preview Code
{
"Content": "Create WinUtil Shortcut",
"category": "Shortcuts",
"panel": "2",
"Order": "a082_",
"Type": "Button",
"ButtonWidth": "300",
"link": "https://christitustech.github.io/winutil/dev/tweaks/Shortcuts/Shortcut"
}
Function: Invoke-WPFShortcut
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"
}