IconLocation プロパティ

アイコンをショートカットに割り当てるか、割り当てられたアイコンを識別します。

object.IconLocation = strIconLocation 

引数

  • object
    WshShortcut オブジェクトです。
  • strIconLocation
    アイコンの格納場所を示す文字列です。この文字列には、絶対パスと、アイコンに関連付けられているインデックスを含める必要があります。詳細については使用例を参照してください。

解説

文字列です。

使用例

次のコードは、IconLocation プロパティの使用例です。

<package>
   <job id="vbs">
      <script language="VBScript">
         set WshShell = WScript.CreateObject("WScript.Shell")
         strDesktop = WshShell.SpecialFolders("Desktop")
         set oShellLink = WshShell.CreateShortcut(strDesktop & "\ショートカット スクリプト.lnk")
         oShellLink.TargetPath = WScript.ScriptFullName
         oShellLink.WindowStyle = 1
         oShellLink.Hotkey = "Ctrl+Alt+e"
         oShellLink.IconLocation = "notepad.exe, 0"  ' ゼロはインデックスです。
         oShellLink.Description = "ショートカット スクリプト"
         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 + "\\ショートカット スクリプト.lnk");
         oShellLink.TargetPath = WScript.ScriptFullName;
         oShellLink.WindowStyle = 1;
         oShellLink.Hotkey = "Ctrl+Alt+e";
         oShellLink.IconLocation = "notepad.exe, 0";  //ゼロはインデックスです。
         oShellLink.Description = "ショートカット スクリプト";
         oShellLink.WorkingDirectory = strDesktop;
         oShellLink.Save();
      </script>
   </job>
</package>

参照

スクリプトを実行する | WshShortcut オブジェクト