Copy Taskbar Icons Windows 7 Sysprep v2

windows7-quicklaunch

Sysprep – Copy Taskbar Icons

Ok, you can thank a colleague of mine (Dinyero Johnson) for this new single vbs script that now copies the taskbar icons and deletes itself.

The vbs script is a little nicer than version one (CMD) because it runs without any windows and in my opinion vbs scripts just run smoother :). Also, it is a single file and the tutorial has less steps.

So for all of you who grabbed version one, lol, grab version 2!!! And if you are using WIM images, you can simply mount your image, replace the script, and unmount/commit.

Repeat instructions are below:

When running sysprep in Windows 7 with the unattend.xml file, you will probably notice that the taskbar icons are something that don’t copy over. Well that is because the icons are not part of the users profile. So the copyprofile=true command does work for almost everything, but it doesn’t copy over your taskbar icons. So here is a script that will do it for you.

Step 1

Download the vbs script (11kb). Click Here to Download or Right Click and Save Target As….
You might have to remove the .txt extension when you are downloading the script. You are going to drop this script into the correct place during audit mode.

(Note – Alternatively you can use a modified version of this script located at http://getgeek.org/wiki/index.php?title=Set_Taskbar_Icons. The script is developed by Wyko ter Haar)

Option Explicit

Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Const CSIDL_STARTMENU = &HB

Dim objShell, objFSO
Dim objCurrentUserStartFolder
Dim strCurrentUserStartFolderPath
Dim objAllUsersProgramsFolder
Dim strAllUsersProgramsPath
Dim objFolder
Dim objFolderItem
Dim colVerbs
Dim objVerb

Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCurrentUserStartFolder = objShell.NameSpace (CSIDL_STARTMENU)
strCurrentUserStartFolderPath = objCurrentUserStartFolder.Self.Path
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path

' - Remove pinned items -

'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
    Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
    Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
    Next
End If

'Windows Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
    Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
    Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
    Next
End If
'Windows Media Player
If objFSO.FileExists(strAllUsersProgramsPath & "\Windows Media Player.lnk") Then
    Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
    Set objFolderItem = objFolder.ParseName("Windows Media Player.lnk")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
    Next
End If

' - Pin to Taskbar -

'Windows Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
	Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
	Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
	Set colVerbs = objFolderItem.Verbs
	For Each objVerb in colVerbs
		If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
	Next
End If

'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
    Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
    Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
    Next
End If

'Mozilla Firefox
If objFSO.FileExists(strAllUsersProgramsPath & "\Mozilla Firefox\Mozilla Firefox.lnk") Then
	Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Mozilla Firefox")
	Set objFolderItem = objFolder.ParseName("Mozilla Firefox.lnk")
	Set colVerbs = objFolderItem.Verbs
	For Each objVerb in colVerbs
		If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
	Next
End If

'Microsoft Word 2010
If objFSO.FileExists(strAllUsersProgramsPath & "\Microsoft Office\Microsoft Word 2010.lnk") Then
	Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office")
	Set objFolderItem = objFolder.ParseName("Microsoft Word 2010.lnk")
	Set colVerbs = objFolderItem.Verbs
	For Each objVerb in colVerbs
		If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
	Next
End If

'Microsoft Excel 2010
If objFSO.FileExists(strAllUsersProgramsPath & "\Microsoft Office\Microsoft Excel 2010.lnk") Then
	Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office")
	Set objFolderItem = objFolder.ParseName("Microsoft Excel 2010.lnk")
	Set colVerbs = objFolderItem.Verbs
	For Each objVerb in colVerbs
		If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
	Next
End If

'Microsoft Outlook 2010
If objFSO.FileExists(strAllUsersProgramsPath & "\Microsoft Office\Microsoft Outlook 2010.lnk") Then
	Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office")
	Set objFolderItem = objFolder.ParseName("Microsoft Outlook 2010.lnk")
	Set colVerbs = objFolderItem.Verbs
	For Each objVerb in colVerbs
		If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
	Next
End If

'Windows Media Player
If objFSO.FileExists(strAllUsersProgramsPath & "\Windows Media Player.lnk") Then
	Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
	Set objFolderItem = objFolder.ParseName("Windows Media Player.lnk")
	Set colVerbs = objFolderItem.Verbs
	For Each objVerb in colVerbs
		If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
	Next
End If

'Delete the script
DeleteSelf

Sub DeleteSelf()       
        Dim objFSO
        'Create a File System Object
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        'Delete the currently executing script
        objFSO.DeleteFile WScript.ScriptFullName
        Set objFSO = Nothing
End Sub

Step 2

Copy the vbs script into the startup folder in the start menu.

Step 3

The vbs script unpins WMP, IE, and Windows Explorer and then repins the icons in the order you want. My file has this order:

Windows Explorer, IE, Firefox, Word, Excel, Outlook, WMP

Step 4

Now run sysprep as you normally would and the script is copied into the default profile. That means for every new user, the script pins the icons in the order you want, the script then deletes itself and never runs again. For the correct procedure on sysprepping your machine, read my Windows 7 Sysprep Tutorial.

Incoming search terms:

  • sysprep taskbar icons
  • it bros taskbar v2
  • it bros copy taskbar
  • windows 7 sysprep v2
  • sysprep windows 7 unpin ie
  • Pingback: Taskbar Icons with Windows 7 Sysprep - The IT Bros

  • Nathan Symington

    This script is quite inefficient if adding 10+ items to the menu and in different configurations. You should implement a Func to stop reusing code and just feed in a folder and shortcut file.

    For example

    pinitem(strAllUsersProgramsPath & “Microsoft Office, Microsoft FrontPage 2003.lnk)
    pinitem(strAllUsersProgramsPath & “Microsoft Office, Microsoft Excel 2010.lnk)
    etc..

    func pinitem($folder,$shortcut)
    if exist $folder $item then pin item
    end func

  • guest

    I would like to use your script but edit it to some other apps I have in my office. For example, I want to remove Firefox from yours and add in Cisco AnyConnect, could you please help me with this.

    • http://theitbros.com/ Brian Jackson

      You can simply download the file and edit it, deleting the Firefox section and replacing it with a new section for Cisco AnyConnect (path to program), etc.

  • Pingback: Sysprep a Windows 7 Machine – Start to Finish V2 - The IT Bros

  • Guest

    Then design your own script and stfu.

  • Pingback: Blank QuickLaunch Icons on View Desktop - VMtoday

  • Doug

    How are you calling (runnning) the script..?

  • Doug

    So the scripts works but placing it in the startup folder during the audit mode does not work. I have spent hours imaging trying to get this to work and no go.

    • Name

      My guess is, he is assuming you are using the option in your unattend.xml to copy the current profile that sysprep is run from into the default profile. This way, by putting it into the startup folder of the current profile, it ends up in the default.

  • adriankeith

    Could this work for domain profiles? Is there any way to, after adding the machine to the domain, add a number of IE favorites to the desktop? I’m just starting with the sysprep guide and downloading some necessary CAB files for my WinPE setup but figured I’d start reading ahead.

    Anyone know if this is possible?

  • Jesse Armbruster

    How would this need reworked for Office 2013 64 bit?

  • Wyko ter Haar

    Based on “Guest’s” comment that this was somewhat inefficient at making lots of changes, I changed the script a bit to make it easier to use. I made a separate remove function for the icons you don’t want to re-add and then I consolidated the add and remove functions for the icons you just want to reorder.

    For the full simple script, as I use it: http://getgeek.org/wiki/index.php?title=Set_Taskbar_Icons

    ——————–

    Here’s my PinItem Sub:

    Sub PinItem(thefolder,theitem)
    ‘thefolder: Either strAllUsersProgramsPath, or a subdirectory thereof which contains the
    ‘ shortcut. This is the all programs menu.
    ‘theitem: The actual shortcut, using the name of the shortcut plus the extension.
    if objFSO.FileExists(thefolder + “” + theitem) then

    Set objFolder = objShell.Namespace(thefolder)
    Set objFolderItem = objFolder.ParseName(theitem)
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
    If Replace(objVerb.name, “&”, “”) = “Unpin from Taskbar” Then objVerb.DoIt
    Next
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
    If Replace(objVerb.name, “&”, “”) = “Pin to Taskbar” Then objVerb.DoIt
    Next
    End if
    End Sub

    ——————–

    Please reply if this helped :)

    • http://theitbros.com/ Brian Jackson

      Wyko ter Haar thank you so much for your contribution. I will add a note to refer to your script in the post. Thanks

      • Wyko ter Haar

        Not a problem. Thanks for the credit :)

  • layer8pro

    Quick question.. Why not work with the Taskbar Links section in the answer file?

    • http://theitbros.com/ Brian Jackson

      Good point. Feel free to share solution you have in mind with our users.

  • Stu

    Hi Brian,
    I am trying to use this script to pin Office 2013 (64bit) icons to Start menu and taskbar, but for the life of me, I cannot get it to work. Can you provide any help? Thank You.

    • rtp1621

      This is how it would look like:

      ‘Microsoft Word 2013

      If objFSO.FileExists(strAllUsersProgramsPath & “Microsoft Office 2013Word 2013.lnk”) Then

      Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “Microsoft Office 2013″)

      Set objFolderItem = objFolder.ParseName(“Word 2013.lnk”)

      Set colVerbs = objFolderItem.Verbs

      For Each objVerb in colVerbs

      If Replace(objVerb.name, “&”, “”) = “Pin to Taskbar” Then objVerb.DoIt

      Next

      End If

      • Moulay Ahmed A Rahhali

        HI
        Is there a chance you can help please?
        I need a script that pin few items in the task bar and start menu
        your help will be very much appreciated

  • Ca Po

    Ran like a charme about 18 months ago.
    Wanted to use it now with a new machine and all Windows updates included – no chance anymore to get it running.
    Maybe new windows update or security settings prevent the script from doing what it should?
    Even if you start it by hand as an administrator NOTHING happens (no unpinning and no pinning)!

  • Mike5314

    Hi, thank you for great script, but can you advice me how to also remove “Windows PowerShell” and “Server Manager”. Thank you in advance.

  • Mike

    Thanks Brian!

    Any ideas on how to pin the Chrome App Launcher?

    It falls under the Google Chrome folder on the start menu.

    I tried this but it didn’t work:

    ‘Google App Launcher
    If objFSO.FileExists(strAllUsersProgramsPath & “Google ChromeGoogle App Launcher.lnk”) Then
    Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “Google Chrome”)
    Set objFolderItem = objFolder.ParseName(“Google App Launcher.lnk”)
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
    If Replace(objVerb.name, “&”, “”) = “Pin to Taskbar” Then objVerb.DoIt
    Next End If

    The Actual target of the shortcut is interesting though:
    “C:Program Files (x86)GoogleChromeApplicationchrome.exe” –show-app-list

    Your help is appreciated!

  • Clement Bowman

    Does this work with plain domain users (non-admins)? Or local accounts only?

  • Headworx

    Hi all,

    OK this does the Taskbar, but I wish to do the same thing with the Start Menu. I presume this is possible and just a different command…….Can anyone help please?

    Also tried looking on the link Wyko ter Haar provided, but it’s unavailable.

    Thanks in advance.