WorkingDirectory プロパティ

作業ディレクトリをショートカットに割り当てるか、ショートカットの作業ディレクトリを識別します。

object.WorkingDirectory = strWorkingDirectory

引数

  • object
    WshShortcut オブジェクトです。
  • strWorkingDirectory
    ショートカットを起動するディレクトリです。

解説

文字列です。

使用例

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

<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>

参照

スクリプトを実行する