VBScript ショートカット作成

VBScriptでショートカットの作成、アイコン画像の設定、作業ディレクトリの設定、引数の設定をするサンプルです。

Option Explicit

' 構文 引数は0以外であれば、引数として設定
Call createshorcut(WorkingDirectory, proguram, ショートカット名, アイコン画像パス, 引数)

Call createshorcut("C:\work", "test.exe", "C:\Users\test\Desktop\sample.lnk", "C:\work\アイコン\sample.ico", "aaa")

Function createshorcut(path, program, name, icon, arg)
	Dim WSH,sc
	Set WSH=CreateObject("WScript.Shell")
	Set sc = WSH.CreateShortcut(name)
	sc.TargetPath = path & "\" & program
	sc.IconLocation = icon
	If arg <> "0" Then
		sc.Arguments = "引数"
	End If
	sc.WorkingDirectory = path
	sc.save
	Set sc = Nothing
	Set WSH = nothing
End Function

Bookmark this on Yahoo Bookmark
Bookmark this on Google Bookmarks
Share on LinkedIn
LINEで送る
Pocket