Skip to content

Instantly share code, notes, and snippets.

@aadennis
Created February 25, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aadennis/89c55bbc5d1825c53e3c3f8ce752dc1d to your computer and use it in GitHub Desktop.
Save aadennis/89c55bbc5d1825c53e3c3f8ce752dc1d to your computer and use it in GitHub Desktop.
Pin a named set of applications to the task bar (e.g. Notepad++, SSMS, VS Code)
# Pin a named set of applications to the task bar (e.g. Notepad++, SSMS, VS Code)
# If there are programs on different drives (e.g. Code on c:, SSMS on f:),
# then a little refactoring is in order.
$application = New-Object -ComObject shell.application
# Programs required
$appSet = 'Notepad++\Notepad++.exe', 'Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe'
# All assumed to be under this root...
$CProgramFiles86 = "C:\Program Files (x86)"
"Pinning programs from [$CProgramFiles86] to the taskbar..."
$ns = $application.NameSpace($CProgramFiles86)
if ($ns -eq $null) {
"Error 1: [$CProgramFiles86] is null. Exiting..."
throw
}
$appSet | % {
$currentProgram = $_
"Pinning [$currentProgram]"
$pn = $ns.ParseName($currentProgram)
if ($pn -eq $null) {
"Error 2: [$currentProgram] was not found. Exiting..."
return
}
$pn.InvokeVerb('TaskbarPin')
}
"Done"
#https://chocolatey.org/packages/notepadplusplus
# iwr https://chocolatey.org/install.ps1 | iex
# choco install notepadplusplus -y -dir="c:\TEMP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment