Solved

Startmenu pinned Items VBS Script

Posted on 2013-12-23
7
1,081 Views
Last Modified: 2013-12-31
I have a vbs script that will add one app to the start menu as a pinned item, how do I add more than one?  It works fine, but need to add more.

I appreciate the help!
startmenu-pinned.vbs
0
Comment
Question by:mystikal1000
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Expert Comment

by:Bxoz
ID: 39736317
http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx

At the end of the article you will find a PinItem.zip file with PinItem.vbs file inside
You can Pin all the item you want with this single ligne
cscript PinItem.vbs /item:<path to exe>
0
 
LVL 1

Author Comment

by:mystikal1000
ID: 39736517
I see, but do you have to run the vbs multiple times to pin for each item?
0
 
LVL 6

Expert Comment

by:Bxoz
ID: 39736586
You can use an Array

Dim myArray(2)
myArray(0) = "C:\Program Files\Microsoft Office 15\root\office15\WINWORD.EXE"
myArray(1) = "C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE"
myArray(2) = "C:\Program Files\Microsoft Office 15\root\office15\OUTLOOK.EXE"
For Each present In myArray
cscript PinItem.vbs /item:present
Next
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 69

Expert Comment

by:Qlemo
ID: 39739783
That script has a lot of noise for such a simple task ... And I don't think you can use CSCRIPT calls in VBS ;-). The general idea is ok, but I would do different:
Sub PinToStartMenu(objFolderItemlink)
  For Each objVerb in objFolderItem.Verbs 
    If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt 
  Next
End Sub

Const CSIDL_COMMON_PROGRAMS = &H17 
Const CSIDL_PROGRAMS = &H2 
Set objShell = CreateObject("Shell.Application") 

strAllUsersProgramsPath = objShell.NameSpace(CSIDL_COMMON_PROGRAMS).Self.Path 
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office") 

PinToStartMenu objFolder.ParseName("Microsoft Word 2010.lnk")
PinToStartMenu objFolder.ParseName("Microsoft Excel 2010.lnk")
PinToStartMenu objFolder.ParseName("Microsoft Outlook 2010.lnk")

Open in new window

or
Const CSIDL_COMMON_PROGRAMS = &H17 
Const CSIDL_PROGRAMS = &H2 
Set objShell = CreateObject("Shell.Application") 

strAllUsersProgramsPath = objShell.NameSpace(CSIDL_COMMON_PROGRAMS).Self.Path 
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office") 

For Each item in array("Word", "Excel", "Outlook")
  For Each objVerb in objFolder.ParseName("Microsoft " & item & " 2010.lnk").Verbs 
    If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt 
  Next
Next

Open in new window

or a mixture of both.
0
 
LVL 1

Author Comment

by:mystikal1000
ID: 39746753
Qlemo,

How do I add a different folder location other than Microsoft Office apps, what if I want to add more apps in different folder locations?
0
 
LVL 6

Assisted Solution

by:Bxoz
Bxoz earned 50 total points
ID: 39746843
Qlemo has right we can call cscript in VBS

So you can create a .bat file in the same directory of PinItem.vbs
in the .bat file

cscript PinItem.vbs /item:"C:\Program Files\Mozilla Firefox\firefox.exe"
cscript PinItem.vbs /item:%windir%\system32\calc.exe
cscript PinItem.vbs /item:"C:\Program Files\Microsoft Office 15\root\office15\WINWORD.EXE"
cscript PinItem.vbs /item:"C:\Program Files\Microsoft Office 15\root\office15\OUTLOOK.EXE"

your system has to be in English otherwise you have to change the verb in the PinItem.vbs
If Replace(itemverb.name, "&", "") = "Pin to Start Menu" Then itemverb.DoIt
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 450 total points
ID: 39747751
We can expand the first code to simplify the task of having different folder locations:
Sub PinToStartMenu(strpath, strlink)
  For Each objVerb in objShell.Namespace(strpath).ParseName(strlink).Verbs 
    If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt 
  Next
End Sub

Const CSIDL_COMMON_PROGRAMS = &H17 
Const CSIDL_PROGRAMS = &H2 
Set objShell = CreateObject("Shell.Application") 

strAllUsersProgramsPath = objShell.NameSpace(CSIDL_COMMON_PROGRAMS).Self.Path 
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office") 

PinToStartMenu strAllUsersProgramsPath & "\Microsoft Office", "Microsoft Word 2010.lnk"
PinToStartMenu strAllUsersProgramsPath & "\xyz", "XYZ.lnk"

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question