LoginSignup
0
1

ログオフのショートカットを PowerShell で作っちゃおう!

Posted at

システム管理者あるあるで沢山のサーバーを管理していると、いちいちログオフするのが面倒くさい。
ならデスクトップにログオフアイコン作っちゃえばいいじゃない。
昔は手で作成していたんだけど、それも面倒になったのでコマンド作っちゃいました。

細かい説明はなしです。

logoff.ps1
# WshShellオブジェクトを作成
$shell = New-Object -ComObject WScript.Shell

# ショートカットへのオブジェクトを作成
$lnk = $shell.CreateShortcut("$HOME\Desktop\ログオフ.lnk")

$lnk.Arguments=$null
$lnk.Description=$null
$lnk.Hotkey=$null
$lnk.IconLocation="%SystemRoot%\system32\SHELL32.dll,44"
$lnk.RelativePath=$null
$lnk.TargetPath="C:\Windows\System32\logoff.exe"
$lnk.WindowStyle=1
$lnk.WorkingDirectory="C:\Windows\system32"

# ショートカットを保存
$lnk.Save()
0
1
0

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
0
1