WindowStyle プロパティ

ウィンドウ スタイルをショートカットに割り当てるか、ショートカットのウィンドウ スタイルの種類を識別します。

object.WindowStyle = intWindowStyle

引数

  • object
    WshShortcut オブジェクトです。
  • intWindowStyle
    実行中のプログラムのウィンドウ スタイルを設定します。

解説

WindowStyle プロパティは整数を返します。

次の表は intWindowStyle に設定できる値を説明しています。

intWindowStyle 内容
1 ウィンドウをアクティブにして表示します。ウィンドウが最小化または最大化されている場合は、元のサイズと位置に戻ります。
3 ウィンドウをアクティブにし、最大化ウィンドウとして表示します。
7 ウィンドウを最小化し、次に上位となるウィンドウをアクティブにします。

使用例

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

<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
         set oUrlLink = WshShell.CreateShortcut(strDesktop & "\マイクロソフトの Web サイト.url")
         oUrlLink.TargetPath = "https://www.microsoft.com"
         oUrlLink.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();
         var oUrlLink = WshShell.CreateShortcut(strDesktop + "\\マイクロソフト Web サイト.url");
         oUrlLink.TargetPath = "https://www.microsoft.com";
         oUrlLink.Save();
      </script>
   </job>
</package>

参照

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