This is because the pinned items are also registered when something is pinned.
Unfortunately, because of this, a batch solution won't work. A vbscript however can make it work. Its a script too, and like .cmd or .bat will work on other computers and through the logon script. Alternatively (but ugly) you can use wscript or cscript to execute your script from the batch file.
To pin an item to the taskbar use the following script:
' print name of item
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Set objShell = CreateObject(“Shell.Application”)
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “\Accessories”)
Set objFolderItem = objFolder.ParseName(“Calculator.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
Wscript.Echo objVerb
Next
and to pin the actual item
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Set objShell = CreateObject(“Shell.Application”)
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & “\Accessories”)
Set objFolderItem = objFolder.ParseName(“Calculator.lnk”)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, “&”, “”) = “Pin to Start Menu” Then objVerb.DoIt
Next
Source: https://blogs.technet.microsoft.com/deploymentguys/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script/