FileCreateShortcut

ショートカット(.lnk)ファイルを作成します。

FileCreateShortcut Target, LinkFile , WorkingDir, Args, Description, IconFile, ShortcutKey, IconNumber, RunState

パラメータ

Target

型:文字列

ショートカットが参照するファイルの名前。そのファイルがシステムと統合されていない限り、絶対パスを含める必要があります(例:Notepad.exe)。ショートカットの作成時にファイルが存在する必要はありませんが、存在しない場合、システムによっては予期せぬ方法でパスが変更される可能性があります。

LinkFile

型:文字列

作成するショートカットファイルの名前。絶対パスが指定されていない場合は、A_WorkingDirにあると仮定されます。必ず拡張子.lnkを付けてください。保存先ディレクトリはすでに存在している必要があります。ファイルがすでに存在する場合は、上書きされます。

WorkingDir

型:文字列

If blank or omitted, LinkFile will have a blank "Start in" field and the system will provide a default working directory when the shortcut is launched. Otherwise, specify the directory that will become Target's current working directory when the shortcut is launched.

Args

型:文字列

If blank or omitted, Target will be launched without parameters. Otherwise, specify the parameters that will be passed to Target when it is launched. パラメータはスペースで区切ってください。パラメータにスペースが含まれる場合は、二重引用符で囲んでください。

説明

型:文字列

If blank or omitted, LinkFile will have no description. Otherwise, specify comments that describe the shortcut (used by the OS to display a tooltip, etc.)

IconFile

型:文字列

If blank or omitted, LinkFile will have Target's icon. Otherwise, specify the full path and name of the icon to be displayed for LinkFile. It must either be an .ICO file or the very first icon of an EXE or DLL file.

ShortcutKey

型:文字列

If blank or omitted, LinkFile will have no shortcut key. Otherwise, specify a single letter, number, or the name of a single key from the key list (mouse buttons and other non-standard keys might not be supported). Do not include modifier symbols. Currently, all shortcut keys are created as Ctrl+Alt shortcuts. For example, if the letter B is specified for this parameter, the shortcut key will be Ctrl+Alt+B.

IconNumber

型:整数

省略されたときは、初期値は 1 です。Otherwise, specify the number of the icon to be used in IconFile. 例えば、2は2番目のアイコンです。

RunState

型:整数

省略されたときは、初期値は 1 です。Otherwise, specify one of the following digits to launch Target minimized or maximized:

エラー処理

失敗した場合は例外がスローされます。

備考

Target might not need to include a path if the target file resides in one of the folders listed in the system's PATH environment variable.

The shortcut key (ShortcutKey) of a newly created shortcut will have no effect unless the shortcut file resides on the desktop or somewhere in the Start Menu. If the shortcut key you choose is already in use, your new shortcut takes precedence.

別の方法として、特別なURLのショートカットを作成する次の例もあります。最初の2つのパラメータは、好みに合わせて変更してください:

IniWrite "https://www.google.com", "C:\My Shortcut.url", "InternetShortcut", "URL"

上記に対して、アイコンを付与するために、以下を任意に追加することができる:

IniWrite <IconFile>, "C:\My Shortcut.url", "InternetShortcut", "IconFile"
IniWrite 0, "C:\My Shortcut.url", "InternetShortcut", "IconIndex"

上記で、0をアイコンのインデックスに置き換え(最初のアイコンには0が使われる)、その代わりに <IconFile>を、URL、EXE、DLL、ICO ファイルと一緒に送信します。例:"C:\Icons.dll", "C:\App.exe", "https://www.somedomain.com/ShortcutIcon.ico"

OSは、.LNKファイルではなくプレーンテキストファイルであっても、上記によって作成された.URLファイルを本物のショートカットとして扱います。

FileGetShortcut, FileAppend

最後のパラメーターに "i "を入れると、ショートカットキーがCtrl+Alt+Iになります。

FileCreateShortcut "Notepad.exe", A_Desktop "\My Shortcut.lnk", "C:³", A_ScriptFullPath, "My Description", "C:³My Icon.ico", "i"