+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, win8 vbs script help in Coding and Web Development; i have the code below (now granted its pilfered rather than written by me) and it sort of works to ...
  1. #1


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,815
    Thank Post
    231
    Thanked 888 Times in 763 Posts
    Rep Power
    301

    win8 vbs script help

    i have the code below (now granted its pilfered rather than written by me) and it sort of works to pin items to taskbar/start screen but if i remove next it fails and if i leave it it adds in an infinate loop any ideas as to whats wrong?

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace("C:\Windows\")
    Set objFolderItem = objFolder.ParseName("Notepad.exe")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
    If Replace(objVerb.name, "&", "") = "Pin to Start" Then objVerb.DoIt
    Wscript.Echo("Added shortcut to Start Screen")
    If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
    Wscript.Echo("Added shortcut to Taskbar")
    next
    End If
    'Next

  2. #2

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    22
    You're code is a bit wrong. The Ifs arent encased properly so the messages will print for every verb and the Next is in the wrong place:

    Code:
    Set objShell = CreateObject("Shell.Application") 
    Set objFolder = objShell.Namespace("C:\Windows\")
    Set objFolderItem = objFolder.ParseName("Notepad.exe") 
    Set colVerbs = objFolderItem.Verbs 
    For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "Pin to Start" Then
            objVerb.DoIt
            Wscript.Echo("Added shortcut to Start Screen")
        End If
        If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then
            objVerb.DoIt
            Wscript.Echo("Added shortcut to Taskbar")
        End If
    Next

  3. Thanks to ChrisMiles from:

    sted (9th November 2012)

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 08:34 AM
  2. help with vbs script
    By sted in forum Scripts
    Replies: 14
    Last Post: 24th February 2012, 11:23 PM
  3. Replies: 13
    Last Post: 22nd April 2011, 03:50 PM
  4. vb script help please
    By mac_shinobi in forum Scripts
    Replies: 13
    Last Post: 31st March 2011, 12:39 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •