473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

VB Script to add taskbar icons not working

I have a script to add taskbar icons on every new user icon. It works, except for the Microsoft Office icons.
Here is the script:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Const CSIDL_COMMON_PROGRAMS = &H17
  4. Const CSIDL_PROGRAMS = &H2
  5. Const CSIDL_STARTMENU = &HB
  6. Const CSIDL_CURRENT_USER_DESKTOP = &H10
  7. Const CSIDL_PUBLIC_DESKTOP = &H19
  8.  
  9. Dim objShell, objFSO
  10.  
  11. Dim objCurrentUserStartFolder
  12. Dim strCurrentUserStartFolderPath
  13.  
  14. Dim objCurrentUserDesktopFolder
  15. Dim strCurrentUserDesktopFolderPath
  16.  
  17. Dim objAllUsersProgramsFolder
  18. Dim strAllUsersProgramsPath
  19.  
  20. Dim objPublicDesktopFolder
  21. Dim strPublicDesktopFolderPath
  22.  
  23. Dim objFolder
  24. Dim objFolderItem
  25. Dim colVerbs
  26. Dim objVerb
  27.  
  28. Set objShell = CreateObject("Shell.Application")
  29. Set objFSO = CreateObject("Scripting.FileSystemObject")
  30.  
  31. Set objCurrentUserStartFolder = objShell.NameSpace (CSIDL_STARTMENU)
  32. strCurrentUserStartFolderPath = objCurrentUserStartFolder.Self.Path
  33.  
  34. Set objCurrentUserDesktopFolder = objShell.NameSpace (CSIDL_CURRENT_USER_DESKTOP)
  35. strCurrentUserDesktopFolderPath = objCurrentUserDesktopFolder.Self.Path
  36.  
  37. Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
  38. strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
  39.  
  40. Set objPublicDesktopFolder = objShell.NameSpace (CSIDL_PUBLIC_DESKTOP)
  41. strCurrentUserDesktopFolderPath = objPublicDesktopFolder.Self.Path
  42.  
  43. ' - Remove pinned items -
  44.  
  45. 'Internet Explorer
  46. If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
  47.     Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
  48.     Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
  49.     Set colVerbs = objFolderItem.Verbs
  50.     For Each objVerb in colVerbs
  51.         If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
  52.     Next
  53. End If
  54.  
  55. 'Google Chrome
  56. If objFSO.FileExists(strAllUsersProgramsPath & "\Google Chrome\Google Chrome.lnk") Then
  57.     Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Google Chrome")
  58.     Set objFolderItem = objFolder.ParseName("Google Chrome.lnk")
  59.     Set colVerbs = objFolderItem.Verbs
  60.     For Each objVerb in colVerbs
  61.         If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
  62.     Next
  63. End If
  64.  
  65. 'Windows Explorer
  66. If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
  67.     Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
  68.     Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
  69.     Set colVerbs = objFolderItem.Verbs
  70.     For Each objVerb in colVerbs
  71.         If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
  72.     Next
  73. End If
  74.  
  75. 'Windows Media Player
  76. If objFSO.FileExists(strAllUsersProgramsPath & "\Windows Media Player.lnk") Then
  77.     Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
  78.     Set objFolderItem = objFolder.ParseName("Windows Media Player.lnk")
  79.     Set colVerbs = objFolderItem.Verbs
  80.     For Each objVerb in colVerbs
  81.         If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
  82.     Next
  83. End If
  84.  
  85. ' - Pin to Taskbar -
  86.  
  87. 'Mozilla Firefox
  88. If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk") Then
  89.     Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\")
  90.     Set objFolderItem = objFolder.ParseName("Mozilla Firefox.lnk")
  91.     Set colVerbs = objFolderItem.Verbs
  92.     For Each objVerb in colVerbs
  93.         If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
  94.     Next
  95. End If
  96.  
  97. 'Windows Explorer
  98. If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
  99.     Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
  100.     Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
  101.     Set colVerbs = objFolderItem.Verbs
  102.     For Each objVerb in colVerbs
  103.         If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
  104.     Next
  105. End If
  106.  
  107. 'Microsoft Office Word
  108. If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\Word 2013.lnk") Then
  109.     Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\")
  110.     Set objFolderItem = objFolder.ParseName("Word 2013.lnk")
  111.     Set colVerbs = objFolderItem.Verbs
  112.     For Each objVerb in colVerbs
  113.             If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
  114.     Next
  115. End If
  116.  
  117. 'Microsoft Office Excel
  118. If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\Excel 2013.lnk") Then
  119.     Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\")
  120.     Set objFolderItem = objFolder.ParseName("Excel 2013.lnk")
  121.     Set colVerbs = objFolderItem.Verbs
  122.     For Each objVerb in colVerbs
  123.             If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
  124.     Next
  125. End If
  126.  
  127. 'Microsoft Office Powerpoint
  128. If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\PowerPoint 2013.lnk") Then
  129.     Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\")
  130.     Set objFolderItem = objFolder.ParseName("PowerPoint 2013.lnk")
  131.     Set colVerbs = objFolderItem.Verbs
  132.     For Each objVerb in colVerbs
  133.             If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
  134.     Next
  135. End If
  136.  
  137. ' - Remove IE shortcuts from start menu -
  138.  
  139. 'Internet Explorer
  140. If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
  141.     objFSO.DeleteFile(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk")
  142. End If
  143.  
  144. 'Internet Explorer 64-bit
  145. If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer (64-bit).lnk") Then
  146.     objFSO.DeleteFile(strCurrentUserStartFolderPath & "\Programs\Internet Explorer (64-bit).lnk")
  147. End If
  148.  
  149.  
  150. ' - Remove Thunderbird from current user desktop -
  151. If objFSO.FileExists(strCurrentUserDesktopFolderPath & "\Mozilla Thunderbird.lnk") Then
  152.     objFSO.DeleteFile(strCurrentUserDesktopFolderPath & "\Mozilla Thunderbird.lnk")
  153. End If
  154.  
  155. ' - Remove Thunderbird from public desktop -
  156. If objFSO.FileExists(strPublicDesktopFolderPath& "\Mozilla Thunderbird.lnk") Then
  157.     objFSO.DeleteFile(strPublicDesktopFolderPath& "\Mozilla Thunderbird.lnk")
  158. End If
  159.  
  160. ' - Remove Google Chrome from current user desktop -
  161. If objFSO.FileExists(strCurrentUserDesktopFolderPath & "\Google Chrome.lnk") Then
  162.     objFSO.DeleteFile(strCurrentUserDesktopFolderPath & "\Google Chrome.lnk")
  163. End If
  164.  
  165. ' - Remove Google Chrome from Public desktop -
  166. If objFSO.FileExists(strPublicDesktopFolderPath & "\Google Chrome.lnk") Then
  167.     objFSO.DeleteFile(strPublicDesktopFolderPath & "\Google Chrome.lnk")
  168. End If
  169.  
  170. 'Delete the script
  171. DeleteSelf
  172.  
  173. Sub DeleteSelf()
  174.         Dim objFSO
  175.         'Create a File System Object
  176.         Set objFSO = CreateObject("Scripting.FileSystemObject")
  177.         'Delete the currently executing script
  178.         objFSO.DeleteFile WScript.ScriptFullName
  179.         Set objFSO = Nothing
  180. End Sub
  181.  
And here is the batch file that places it:

Expand|Select|Wrap|Line Numbers
  1. mkdir "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
  2. copy /y SetShortcuts.vbs "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

Any ideas why this wouldn't be working?
Jul 24 '15 #1
0 1506

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: pantagruel | last post by:
The following does not work in firefox: <script defer="defer"> var x=document.getElementsByName("repositoryNamespace") alert(x.length + " elements!")
3
by: Raymond | last post by:
Hello folks, My script is as below: parent.menu.location.reload(true); parent.frames("menu").TreeView1.CollapseAll(); parent.frames("menu").TreeView1.SelectNodeById(id);...
10
by: =?ISO-8859-1?Q?Fran=E7oise_Debat?= | last post by:
Hello, I wonder if anybody can help. I have an IP blocking script which displays a blank screen if an IP is detected from a list in an external file. The problem is, the script only reads the...
5
by: CoolForU | last post by:
this is my code and i call this code from code behinde file on page load like this useragree.Attributes.Add("onclick", "CheckSelection();") this is working fine with IE but not working with...
0
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, How can i fetch the list of icons from taskbar...... like sound, internet connectivity, antivirus icons etc... Thanx >> ALI <<
2
by: bahnfire | last post by:
Hi, I am hoping that I finally have the right group :-) I am using Visual C++ Express 2008 and am trying to change the taskbar icon that I am using (notifyIcon1) as some state changes (button...
1
by: pandharinath | last post by:
I want to display fields(row) selected from grid in popup window to textboxes in Opener window. I have written code as follows : Main Opener window protected void Button1_Click(object...
3
by: mark roldan | last post by:
Hi, this is a code for form verification... I added the function results() then the entire script is now not working. Need help... *note that if I omit the results() function, other functional parts...
1
by: ranjeeeet | last post by:
my image upload script is not working while insert script is working
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.