WshShortcut オブジェクト

Cc364438.wsWshShortcutObject(ja-jp,MSDN.10).gif

ショートカットへのオブジェクト参照を作成します。

使用例

次のコードは、実行中のスクリプトへのショートカットを作成する例です。

<package>
   <job id="vbs">
      <script language="VBScript">
         set WshShell = WScript.CreateObject("WScript.Shell")
         strDesktop = WshShell.SpecialFolders("Desktop")
         set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
         oShellLink.TargetPath = WScript.ScriptFullName
         oShellLink.WindowStyle = 1
         oShellLink.Hotkey = "CTRL+SHIFT+F"
         oShellLink.IconLocation = "notepad.exe, 0"
         oShellLink.Description = "Shortcut Script"
         oShellLink.WorkingDirectory = strDesktop
         oShellLink.Save
      </script>
   </job>

   <job id="js">
      <script language="JScript">
         var WshShell = WScript.CreateObject("WScript.Shell");
         strDesktop = WshShell.SpecialFolders("Desktop");
         var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut Script.lnk");
         oShellLink.TargetPath = WScript.ScriptFullName;
         oShellLink.WindowStyle = 1;
         oShellLink.Hotkey = "CTRL+SHIFT+F";
         oShellLink.IconLocation = "notepad.exe, 0";
         oShellLink.Description = "Shortcut Script";
         oShellLink.WorkingDirectory = strDesktop;
         oShellLink.Save();
      </script>
   </job>
</package>

プロパティ

Arguments プロパティ | Description プロパティ | FullName プロパティ (WshShortcut オブジェクト) | Hotkey プロパティ | IconLocation プロパティ | TargetPath プロパティ | WindowStyle プロパティ | WorkingDirectory プロパティ

メソッド

Save メソッド

参照

スクリプトを実行する | CreateShortcut メソッド