EZLearn 顯示在 Windows 開始功能表
如何把你的程式, 在安裝過程中自動放到使用者的"開始功能表" 呢?
下面是一個我在安裝 EZLearn 語言學習機的範例
安裝
' install EZLearn.vbs (使用 cscript EZLearn.vbs 執行) by Jing
' Step 1: 在目前目錄建立捷徑 EZLearn.lnk
Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = oWS.CurrentDirectory+"\EZLearn.LNK"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = oWS.CurrentDirectory+"\EZLearn.exe"
'設定捷徑的工作路徑: 與執行檔一樣 (如果不指定 ,則預設路徑
'為 C:\Documents and Settings\使用者帳號)
oLink.WorkingDirectory = oWS.CurrentDirectory
oLink.Save
'Step 2: 把 shortcut 固定到開始功能表 (pin to start menu)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(oWS.CurrentDirectory)
Set objApp = objFolder.ParseName("EZLearn.LNK")
If objApp Is Nothing Then
MsgBox ("Executable not found. Make sure the path and file name are correct.")
Else
objApp.InvokeVerb ("P&in to Start Menu")
End If
移除
'把 EZLearn.lnk 從 開始 menu 移除
Set oWS = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(oWS.CurrentDirectory)
Set objApp = objFolder.ParseName("EZLearn.LNK")
If objApp Is Nothing Then
MsgBox ("Executable not found. Make sure the path and file name are correct.")
Else
objApp.InvokeVerb ("Unp&in from Start Menu")
End If
' 參考資料:
'http://www.vbforums.com/showthread.php?t=534820
沒有留言:
張貼留言