Solved

Startmenu pinned Items VBS Script

Posted on 2013-12-23
7
1,095 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
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.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

821 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