Save メソッド
ショートカット オブジェクトを保存します。
object
.Save
引数
- object
WshShortcut オブジェクトまたは WshUrlShortcut オブジェクトです。
解説
CreateShortcut メソッドを使ってショートカット オブジェクトを作成しプロパティを設定したら、Save メソッドを使ってそのショートカットをディスクに保存する必要があります。Save メソッドは、ショートカット オブジェクトの FullName プロパティの情報に基づいて、ショートカットを保存する場所を決定します。作成できるのはシステム オブジェクトへのショートカットに限定されます。これにはファイル、ディレクトリ、およびドライブが含まれます (プリンタのリンクやスケジュールされたタスクは含まれません)。
使用例
次のコードは、1 つの .wsf ファイルを使用して、異なるスクリプト言語 (VBScript および JScript) で記述された 2 つのジョブを実行する例です。ジョブの機能はどちらも同じで、実行中のスクリプトへのショートカットと www.microsoft.com への URL ショートカットを作成します。
<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+SHIFT+F"
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+SHIFT+F";
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 オブジェクト | WshUrlShortcut オブジェクト | FullName プロパティ | TargetPath プロパティ | WindowStyle プロパティ | Hotkey プロパティ | IconLocation プロパティ | Description プロパティ | WorkingDirectory プロパティ