Hi

My requirement is to pinning webpage to task bar. My code is as follows

Sub CreateShortcut()

Set WshShell = CreateObject("WScript.Shell")
'strDesktop = WshShell.SpecialFolders("Desktop")
strDesktop = CreateObject("WScript.Shell").SpecialFolders("Desktop")
Set oUrlLink = WshShell.CreateShortcut(strDesktop & "\msn.lnk")
oUrlLink.TargetPath = "http://www.msn.com"

oUrlLink.Save

End Sub


Public Sub PinApplicationToTaskBar(AppPathAndName, ShortcutName, OnStartMenu)
'This is on for a soft failure. Uncomment this if error checking for a hard failure is needed for debugging.
On Error Resume Next

Dim FileSystemObj, ObjShell, ObjShellApp
Set ObjShell = CreateObject("WScript.Shell")
ObjShell.popup ("Hi")
Set FileSystemObj = CreateObject("Scripting.FileSystemObject")

'Create a temp location for the short-cut to exist
TempShortcutLocation = FileSystemObj.GetFolder(ObjShell.ExpandEnvironmentStrings("%TEMP%"))
'Where is it being pinned? Determine the location where the pinned item will reside
If (Trim(LCase(OnStartMenu)) = "true") Then ' pinned to start menu
HasAlreadyBeenPinnedShortCut = ObjShell.ExpandEnvironmentStrings("%APPDATA%") & _
"\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu"
Else
HasAlreadyBeenPinnedShortCut = ObjShell.ExpandEnvironmentStrings("%APPDATA%") & _
"\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"

End If
'Temporary location for the application short-cut
TempShortcut = TempShortcutLocation & "\" & ShortcutName & ".lnk"
'Possible location of a pinned item
HasAlreadyBeenPinnedShortCut = HasAlreadyBeenPinnedShortCut & "\" & ShortcutName & ".lnk"

'If this already exists, than exit this procedure. The application has already been pinned.
If (FileSystemObj.FileExists(HasAlreadyBeenPinnedShortCut)) Then
'MsgBox(HasAlreadyBeenPinnedShortCut & " Already Pinned")
Exit Sub
End If
'Create a short-cut using the shell
Set lnk = ObjShell.CreateShortcut(TempShortcut)
lnk.TargetPath = AppPathAndName ' Full application path and name
lnk.Arguments = ""
lnk.Description = ShortcutName 'The name that appears on the start menu.
lnk.Save

Set ObjShellApp = CreateObject("Shell.Application")

'Get the newly created short-cut full path
Set ShortCutToPin = ObjShellApp.Namespace(TempShortcutLocation)

If (FileSystemObj.FileExists(TempShortcut)) Then
Dim ShortCutToPinItem, verb
'Set the location to pin the item to do based on the passed OnStartMenu argument
If (Trim(LCase(OnStartMenu)) = "true") Then
verbToDo = "Pin to Start Men&u"
Else
verbToDo = "Pin to Tas&kbar"
End If
For Each ShortCutToPinItem In ShortCutToPin.Items()
'Look for the pinning verb when the temporary short-cut name matches the passed ShortcutName argument
If (ShortCutToPinItem.Name = ShortcutName) Then
'Loop through the shell object's (the short-cut) commands looking for the pinning method.
For Each verb In ShortCutToPinItem.Verbs
'The verb matches the verbToDo so pin it to verb's defined location
If (verb.Name = verbToDo) Then verb.DoIt
Next
End If
Next
'Delete the temporary short-cut used to pin the application
FileSystemObj.DeleteFile (TempShortcut)
End If
'clean up
Set ObjShell = Nothing
Set FileSystemObj = Nothing
Set ObjShellApp = Nothing
End Sub

Above function is working fine if i try with
Call PinApplicationToTaskBar("C:\Program Files (x86)\Notepad++.exe", "Notepad", "false")

But if i try with the following(saving a webpage)
Call PinApplicationToTaskBar("C:\Users\<User Name>\Desktop\msn.url", "msn", "false")

Outcome is not as expected.

Could any one suggest me the wayout?

regards
Gautam