mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-26 06:18:17 +01:00
Add create-shortcut.ps1
This commit is contained in:
parent
8b608c57a2
commit
3af684d749
@ -20,6 +20,7 @@ close-thunderbird.ps1, closes Mozilla Thunderbird gracefully
|
||||
close-vlc.ps1, closes the VLC media player gracefully
|
||||
close-windows-terminal.ps1, closes Windows Terminal gracefully
|
||||
configure-git.ps1, sets up the Git user configuration
|
||||
create-shortcut.ps1, creates a shortcut
|
||||
create-symlink.ps1, creates a symbolic link
|
||||
csv-to-text.ps1, converts the given CSV file into a text list
|
||||
daily-tasks.sh, execute PowerShell scripts automatically as daily tasks (Linux only)
|
||||
|
|
@ -72,6 +72,7 @@ Collection of PowerShell Scripts
|
||||
-----------------------------
|
||||
* [check-symlinks.ps1](Scripts/check-symlinks.ps1) - checks every symlink in the given directory tree
|
||||
* [check-xml-file.ps1](Scripts/check-xml-file.ps1) - checks the given XML file for validity
|
||||
* [create-shortcut.ps1](Scripts/create-shortcut.ps1) - creates a shortcut
|
||||
* [create-symlink.ps1](Scripts/create-symlink.ps1) - creates a symbolic link
|
||||
* [decrypt-file.ps1](Scripts/decrypt-file.ps1) - encrypts the given file
|
||||
* [encrypt-file.ps1](Scripts/encrypt-file.ps1) - encrypts the given file
|
||||
|
35
Scripts/create-shortcut.ps1
Executable file
35
Scripts/create-shortcut.ps1
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./create-shortcut.ps1 [<shortcut>] [<target>] [<description>]
|
||||
.DESCRIPTION creates a new shortcut
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param($Shortcut = "", $Target = "", $Description)
|
||||
|
||||
if ($Shortcut -eq "" ) {
|
||||
$Shortcut = read-host "Enter filename of shortcut"
|
||||
}
|
||||
if ($Target -eq "" ) {
|
||||
$Target = read-host "Enter path to target"
|
||||
}
|
||||
if ($Description -eq "" ) {
|
||||
$Description = read-host "Enter description"
|
||||
}
|
||||
|
||||
try {
|
||||
$sh = new-object -ComObject WScript.Shell
|
||||
$shortcut = $sh.CreateShortcut("$Shortcut.lnk")
|
||||
$shortcut.TargetPath = "$Target"
|
||||
$shortcut.WindowStyle = "1"
|
||||
$shortcut.IconLocation = "C:\Windows\System32\SHELL32.dll, 3"
|
||||
$shortcut.Description = "$Description"
|
||||
$shortcut.save()
|
||||
|
||||
write-host -foregroundColor green "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user