2
2

More than 1 year has passed since last update.

PowershellでWindows10のタスクバーにピン留めする

Last updated at Posted at 2022-03-03

できないという情報ばかりでしたが、できる方法を見つけたので記載します。

ハマりポイント

1.タスク バーにピン留めする(K) は駄目((K)が不要)。
(右クリックメニューのエクスプローラ上とスタートメニュー上の表示の違い)

2.設定後にエクスプローラの再起動やサインアウト&インが必要

タスクバーにピン留めするPowershell

CreateTaskPIN.ps1
#########################################################
# ショートカットをタスクバーにピン止めする
#########################################################
function Pin2Taskbar($FileFullPath){
	if( Test-Path $FileFullPath ){
		$PathName = Split-Path $FileFullPath -Parent
		$FileNmae = Split-Path $FileFullPath -Leaf

		$Shell = new-object -com "Shell.Application"
		$TergetFolder = $Shell.Namespace( $PathName )
		$TergetItem = $TergetFolder.ParseName( $FileNmae )
		$Verb = $TergetItem.Verbs() | ? {($_.Name -match "^タスク バーにピン留めする") -or ($_.Name -match "^&Pin to Taskbar")}
		$Verb.DoIt()
	}
}

Pin2Taskbar $Args[0]

実行ファイル(bat)

1.※ps1と同パスに配置する。
2.右クリック「管理者として実行」する。

CREATE_IE_PINSTOP.bat
@echo off
echo;

REM ショートカットのフルパス
set LNK="%appdata%\Microsoft\Windows\Start Menu\Programs\Accessories\Internet Explorer.lnk"
REM Powershell実行環境設定有無に関わらず実行可能にする設定
set POW=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
set PSExecutionPolicyPreference=RemoteSigned
REM エクスプローラ再起動コマンド
set REB="spps -name explorer"

%POW% %~dp0CreateTaskPIN.ps1 %LNK%
echo;
%POW% %REB%

pause
2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2