Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Startmenu pinned Items VBS Script

Posted on 2013-12-23
7
Medium Priority
?
1,132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 71

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 200 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 71

Accepted Solution

by:
Qlemo earned 1800 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

610 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