WshShell.CreateShortcutクリエイトショートカット メソッド

任意のパスにショートカット(*.lnk)やURLショートカット(*.url)を新規に作成します。WshShortcut オブジェクト(*.lnkの場合)もしくはWshURLShortcut オブジェクト(*.urlの場合)が返ります。作成したショートカットはWshShell.CreateShortcutを実行時に保存されます。

構文
  1. Object = WshShell.CreateShortcut( strPathname )
引数
strPathname 省略可
作成するショートカットのパスとファイル名
戻り値

プログラム実行例

メモ帳を起動するショートカットファイルを作成

カレントディレクトリにメモ帳.lnkのショートカットリンクを作成します。

UWSC
使用関数

コマンドプロンプトのショートカットを生成

デスクトップにコマンドプロンプトへのショートカットリンクを作成します。

UWSC
DIM WshShell = CREATEOLEOBJ("WScript.Shell")
DIM WshShortcut = WshShell.CreateShortcut("メモ帳.lnk")
WshShortcut.TargetPath = "C:\Windows\System32\notepad.exe"
WshShortcut.Save
結果
使用関数
解説

デスクトップにChromeのショートカットを作成

デスクトップにGoogle Chromeでhttps://google.co.jpをシークレットモードで起動するショートカットを作成します。

UWSC
CONST ssfDesktop = 0

DIM Shell = CREATEOLEOBJ("Shell.Application")
DIM path = Shell.NameSpace(ssfDesktop).Self.Path

DIM WshShell = CREATEOLEOBJ("WScript.Shell")
DIM WshShortcut = WshShell.CreateShortcut(path + "\cmd.lnk")

WITH WshShortcut
	.IconLocation = "C:\Windows\system32\imageres.dll, 11"
	.TargetPath = "C:\WINDOWS\system32\cmd.exe"
	.WindowStyle = 3
	.WorkingDirectory = "%LOCALAPPDATA%"
	.Save
ENDWITH
結果
使用関数
解説

この記事は役に立ちましたか?

はい
いいえ
ご協力ありがとうございます。