wrote :: 2007.06.01
Sub Sample1()
Dim WSH, LnkFile, DeskTopPath As String, LnkFileName As String
Set WSH = CreateObject("WScript.Shell")
DeskTopPath = WSH.SpecialFolders("Desktop")
LnkFileName = DeskTopPath & "\メモ帳.lnk"
Set LnkFile = WSH.CreateShortcut(LnkFileName)
LnkFile.TargetPath = "%SystemRoot%\System32\notepad.exe"
LnkFile.Save
Set LnkFile = Nothing
Set WSH = Nothing
End Sub
CreateShortcut メソッド
ショートカットまたは URL ショートカットへのオブジェクト参照を作成します。
object.CreateShortcut(strPathname)
解説
CreateShortcut メソッドは、WshShortcut オブジェクトまたは WshURLShortcut オブジェクトのいずれかを返します。
Sub Sample2()
Dim WSH, LnkFile, DeskTopPath As String, LnkFileName As String
Set WSH = CreateObject("WScript.Shell")
DeskTopPath = WSH.SpecialFolders("Desktop")
LnkFileName = DeskTopPath & "\メモ帳.lnk"
Set LnkFile = WSH.CreateShortcut(LnkFileName)
MsgBox LnkFile.TargetPath
Set LnkFile = Nothing
Set WSH = Nothing
End Sub
