Perhaps the following will help. I am not a scripting guy but you may be
able to test to figure it out:
Use the Shell object and use the "Pin to Start Menu" verb to achieve the
result. Below is a sample code that should work on a genric case. One more
thing I notice was that the Pinned items are per user and not global.
Public objShell 'As New WshShell
Public objShell32 'As New Shell32.Shell
Public strStartMenuFolderPath 'As String
const ssfCOMMONSTARTMENU = 22
Call Main()
'********************
' Main *
'********************
Sub Main()
Set objShell = CreateObject("Wscript.Shell")
Set objShell32 = CreateObject("Shell.Application")
strAnswer = MsgBox("Do you want to create short cut ?", vbYesNo)
strStartMenuFolderPath = objShell.SpecialFolders("AllUsersStartMenu")
If strAnswer = vbYes Then
CreateShortcuts
Else
DeleteShortCuts
End If
End Sub
'********************
' Create ShortCuts *
'********************
Sub CreateShortcuts()
strShortCutName = InputBox("Enter the ShortCut Name")
strTargetPath = InputBox("Enter The Target file path")
Set objShellLink = objShell.CreateShortCut(strStartMenuFolderPath & "\" &
strShortCutName & ".lnk")
objShellLink.TargetPath = strTargetPath
objShellLink.WorkingDirectory = strStartMenuFolderPath
objShellLink.Save
strPinToStartMenu = MsgBox("Do you want to pin the Item to Start Menu",
vbYesNo)
If strPinToStartMenu = vbYes Then
PinToStartMenu (strShortCutName)
End If
End Sub
'********************
' Delete ShortCuts *
'********************
Sub DeleteShortCuts()
set objFSO = CreateObject("Scripting.FileSystemObject")
Set objStartMenuFolder = objFSO.GetFolder(strStartMenuFolderPath)
strShortCutToDelete = InputBox("Please Enter the Shortcut's Name to Delete
(without
the extension)")
For Each objFile In objStartMenuFolder.Files
strFileName = objFSO.GetBaseName(objFile.Path)
If StrComp(strFileName, strShortCutToDelete) = 0 Then
UnPinFromStartMenu (strFileName)
objFSO.DeleteFile (objFile.Path)
Exit For
End If
Next
End Sub
'********************
' Pin To Start Menu *
'********************
Public Sub PinToStartMenu(strShortCutName) 'As String
'ssfCOMMONSTARTMENU is a ShellSpecialFolder Constant
'All the constants can be obtained from
'
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pl
atform/s
hell/reference/objects/shell/shellspecialfolderconstants.asp
Set objFolder = objShell32.NameSpace(ssfCOMMONSTARTMENU)
Set colFolderItems = objFolder.Items
For Each objFolderItem In colFolderItems
If StrComp(objFolderItem.Name, strShortCutName) = 0 Then ' The verbs
are
what you get when a right click on the object is done.
objFolderItem.InvokeVerb ("P&in to Start menu")
Exit For
End If
Next
End Sub
'************************
' UnPin From Start Menu *
'************************
Public Sub UnPinFromStartMenu(strShortCutName) 'As String
Set objFolder = objShell32.NameSpace(ssfCOMMONSTARTMENU)
Set colFolderItems = objFolder.Items
For Each objFolderItem In colFolderItems
If StrComp(objFolderItem.Name, strShortCutName) = 0 Then
objFolderItem.InvokeVerb ("Unp&in from Start menu")
Exit For
End If
Next
End Sub
Buz Brodin
MCSE NT4 / Win2K
Microsoft Enterprise Domain Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>