这是因为在钉扎某些物品时也会记录钉扎的项目。
不幸的是,因此,批处理解决方案将无法工作。但是,vbscript可以使其工作。它也是一个脚本,例如.cmd或.bat可以在其他计算机上并通过登录脚本运行。另外(但很丑),您可以使用wscript或cscript从批处理文件执行脚本。
要将项目固定到任务栏,请使用以下脚本:
' 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
并固定实际物品
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
来源:https : //blogs.technet.microsoft.com/deploymentguys/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script/