Link to home
Start Free TrialLog in
Avatar of mystikal1000
mystikal1000

asked on

Add toolbar to taskbar using a script in Windows 7

Is there a way to use PS or VBS to run a script to add a folder to the taskbar using the toolbar properties.  I would like to add a folder under the start menu to the toolbar automatically.  We want to deploy this to all machines in the environment, however I don't want it to mess up other toolbars that are enabled on customer machines if applicable.
Avatar of zalazar
zalazar

Another approach would be to create a shortcut to this folder e.g. within the Start Menu and then pin this shortcut to the taskbar.
Create a shortcut e.g. named Accessories in directory
"C:\ProgramData\Microsoft\Windows\Start Menu\Programs"
pointing to
C:\Windows\explorer.exe /e,"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories"

and then use the following VBS script to pin this shortcut to the taskbar.

The location of the shortcut, the name Accessories and the directory where it's pointing to should of course be changed to what you need.

'*********************************************************************
'* Pin Shortcuts
'*********************************************************************
Const PinTask = "Pin to Taskbar"
Const PinStart = "Pin to Start Menu"
Const UnpTask = "Unpin from Taskbar"
Const UnpStart = "Unpin from Start Menu"

Dim fso, objShell, strShortcut

Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

' Pin shortcut to taskbar
strShortcut = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories.lnk"
call PinItem(strShortcut, PinTask)


Set objShell = Nothing
Set fso = Nothing

Wscript.quit 0
'---------------------------------------------------------------------
' --------  SUBS  --------
'---------------------------------------------------------------------
Sub PinItem(sShortcut, sPinType)
  Dim sFolderPath, sFileName
  Dim objFolder, objFolderItem, colVerbs, objVerb

  If fso.FileExists(sShortcut) = False Then
    Exit Sub
  End If

  sFolderPath = fso.GetParentFolderName(sShortcut)
  sFileName = fso.GetFileName(sShortcut)

  Set objFolder = objShell.Namespace(sFolderPath)
  Set objFolderItem = objFolder.ParseName(sFileName)
  Set colVerbs = objFolderItem.Verbs
  For Each objVerb in colVerbs
    If Replace(objVerb.name, "&", "") = sPinType Then objVerb.DoIt
  Next

  Set colVerbs = Nothing
  Set objFolderItem = Nothing
  Set objFolder = Nothing
End Sub

Open in new window

Avatar of mystikal1000

ASKER

Zalazar - thanks for the effort, but really just need the toolbar, a pin shortcut will not work from a customer perspective.  I guess there is no PS or VBS script to do this?
I understand.
So far I could not find any PowerShell, VBS script or other code for this.
The settings are stored in the registry in REG_BINARY values which makes it difficult.
ASKER CERTIFIED SOLUTION
Avatar of zalazar
zalazar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is exactly what I am looking for!!!  Thank you very much, you deserve 1000 points!
Very good that it's what you were looking for.
Appreciated to hear that, thank you very much too.