WshSpecialFolders オブジェクト
Windows の特殊フォルダのコレクションへのアクセスを提供します。
解説
WshShell オブジェクトの SpecialFolders プロパティは、特殊フォルダのコレクションである WshSpecialFolders オブジェクトを返します。このコレクションには、[デスクトップ] フォルダ、[スタート メニュー] フォルダ、個人用ドキュメントのフォルダなど、Windows の特殊フォルダへの参照が含まれています。このコレクションでは、フォルダ名をインデックスとして指定して、特殊フォルダへのパスを取得します。特殊フォルダへのパスは使用環境によって異なります。また、特殊フォルダ内に格納される情報は、コンピュータ システムにログオンするユーザーごとに異なります。同一コンピュータ システム上で複数のユーザーがアカウントを所有している場合、ハードディスクには複数の特殊フォルダ セットが格納されます。
使用できる特殊フォルダは次のとおりです。
- AllUsersDesktop
- AllUsersStartMenu
- AllUsersPrograms
- AllUsersStartup
- Desktop
- Favorites
- Fonts
- MyDocuments
- NetHood
- PrintHood
- Programs
- Recent
- SendTo
- StartMenu
- Startup
- Templates
使用例
次のスクリプトは、WshSpecialFolders オブジェクトの使用例です。
<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>