Ветеран
Сообщения: 1639
Благодарности: 50
|
Профиль
|
Отправить PM
| Цитировать
Казбек,
Цитата Казбек:
По первой ссылке там несколько решений. »
|
Я посмотрел итоговое - оно основано на решении, приведенном в статье
Цитата Казбек:
Pin Items to the Start Menu or Windows 7 Taskbar via Script »
|
, но вопрос
Цитата The_Immortal:
каким образом зафигачить это для дефолтного пользователя »
|
остается открытым.
UPD: Кстати, Вы не могли бы его протестировать у себя?
pinunpin.vbs
Код:
Dim iArgCount
iArgCount = WScript.Arguments.Count
If (iArgCount <> 3) Then
ShowUsage
End If
Dim sAction,sSMorTB,sFilePath
sAction = LCase(WScript.Arguments.Item(0))
sSMorTB = LCase(WScript.Arguments.Item(1))
sFilePath = LCase(WScript.Arguments.Item(2))
If (sAction <> "pin") And (sAction <> "unpin") Then
WScript.Echo "Error: Invalid Action: '" & sAction & "'"
ShowUsage
End If
If (sSMorTB <> "startmenu") And (sSMorTB <> "taskbar") Then
WScript.Echo "Error: Invalid Location: '" & sSMorTB & "'"
ShowUsage
End If
If (sAction = "pin") And (sSMorTB = "startmenu") Then PinToStartMenu sFilePath
If (sAction = "pin") And (sSMorTB = "taskbar") Then PinToTaskBar sFilePath
If (sAction = "unpin") And (sSMorTB = "startmenu") Then UnpinFromStartMenu sFilePath
If (sAction = "unpin") And (sSMorTB = "taskbar") Then UnpinFromTaskBar sFilePath
WScript.Quit
Sub ShowUsage
WScript.Echo "Usage: " & WScript.ScriptName & " [PIN|UNPIN] [STARTMENU|TASKBAR] File"
WScript.Echo vbTab & WScript.ScriptName & " PIN startmenu C:\apps\tools\wmopener.exe"
WScript.Echo vbTab & WScript.ScriptName & " unpin TASKBAR ""C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk"""
WScript.Quit
End Sub
Sub PinToStartMenu(Required_Path_To_Item)
' See
' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
Set s_oFSO = CreateObject("Scripting.FileSystemObject")
Set s_oShell = CreateObject("Shell.Application")
s_FullItemPath = Required_Path_To_Item
If Not (s_oFSO.FileExists(s_FullItemPath)) Then
WScript.Echo "Error Pinning File '" & s_FullItemPath & "' to Start Menu: File Does Not Exist!"
Exit Sub
End If
s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
Set s_oFolder = s_oShell.Namespace(s_sItemFolder)
Set s_oFolderItem = s_oFolder.ParseName(s_sItemName)
Set s_colVerbs = s_oFolderItem.Verbs
For Each s_oVerb in s_colVerbs
If Replace(s_oVerb.name, "&", "") = "Pin to Start Menu" Then
WScript.Echo "Pinning '" & s_FullItemPath & "' to Start Menu"
's_oVerb.DoIt
ElseIf Replace(s_oVerb.name, "&", "") = "Unpin from Start Menu" Then
WScript.Echo "Error: Item '" & s_FullItemPath & "' is Already Pinned to Start Menu"
End If
Next
End Sub
Sub PinToTaskBar(Required_Path_To_Item)
' See
' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
Set s_oFSO = CreateObject("Scripting.FileSystemObject")
Set s_oShell = CreateObject("Shell.Application")
s_FullItemPath = Required_Path_To_Item
If Not (s_oFSO.FileExists(s_FullItemPath)) Then
WScript.Echo "Error Pinning File '" & s_FullItemPath & "' to TaskBar: File Does Not Exist!"
Exit Sub
End If
s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
Set s_oFolder = s_oShell.Namespace(s_sItemFolder)
Set s_oFolderItem = s_oFolder.ParseName(s_sItemName)
Set s_colVerbs = s_oFolderItem.Verbs
For Each s_oVerb in s_colVerbs
If Replace(s_oVerb.name, "&", "") = "Pin to Taskbar" Then
WScript.Echo "Pinning '" & s_FullItemPath & "' to Taskbar"
's_oVerb.DoIt
ElseIf Replace(s_oVerb.name, "&", "") = "Unpin from Taskbar" Then
WScript.Echo "Error: Item '" & s_FullItemPath & "' is Already Pinned to Taskbar"
End if
Next
End Sub
Sub UnpinFromStartMenu(Required_Path_To_Item)
' See
' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
Set s_oFSO = CreateObject("Scripting.FileSystemObject")
Set s_oShell = CreateObject("Shell.Application")
s_FullItemPath = Required_Path_To_Item
If Not (s_oFSO.FileExists(s_FullItemPath)) Then
WScript.Echo "Error Unpinning File '" & s_FullItemPath & "' From Start Menu: File Does Not Exist!"
Exit Sub
End If
s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
Set s_oFolder = s_oShell.Namespace(s_sItemFolder)
Set s_oFolderItem = s_oFolder.ParseName(s_sItemName)
Set s_colVerbs = s_oFolderItem.Verbs
For Each s_oVerb in s_colVerbs
If Replace(s_oVerb.name, "&", "") = "Unpin from Start Menu" Then
WScript.Echo "Unpinning '" & s_FullItemPath & "' From Start Menu"
's_oVerb.DoIt
ElseIf Replace(s_oVerb.name, "&", "") = "Pin to Start Menu" Then
WScript.Echo "Error: Item '" & s_FullItemPath & "' is Not Pinned to Start Menu"
End if
Next
End Sub
Sub UnpinFromTaskBar(Required_Path_To_Item)
' See
' http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx?PageIndex=3
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Dim s_oFSO, s_oShell, s_oAllUsersProgramsFolder
Dim s_oFolder, s_oFolderItem, s_colVerbs, s_oVerb
Dim s_FullItemPath, s_sItemFolder, s_sItemName, s_sAllUsersProgramsPath
Set s_oFSO = CreateObject("Scripting.FileSystemObject")
Set s_oShell = CreateObject("Shell.Application")
s_FullItemPath = Required_Path_To_Item
If Not (s_oFSO.FileExists(s_FullItemPath)) Then
WScript.Echo "Error Unpinning File '" & s_FullItemPath & "' from Taskbar: File Does Not Exist!"
Exit Sub
End If
s_sItemFolder = s_oFSO.GetParentFolderName(s_FullItemPath)
s_sItemName = s_oFSO.GetFileName(s_FullItemPath)
Set s_oFolder = s_oShell.Namespace(s_sItemFolder)
Set s_oFolderItem = s_oFolder.ParseName(s_sItemName)
Set s_colVerbs = s_oFolderItem.Verbs
For Each s_oVerb in s_colVerbs
If Replace(s_oVerb.name, "&", "") = "Unpin from Taskbar" Then
WScript.Echo "Unpinning '" & s_FullItemPath & "' from Taskbar"
's_oVerb.DoIt
ElseIf Replace(s_oVerb.name, "&", "") = "Pin to Taskbar" Then
WScript.Echo "Error: Item '" & s_FullItemPath & "' is Not Pinned to Taskbar"
End if
Next
End Sub
Использование:
Код:
pinunpin.vbs pin taskbar "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
У меня выдает ошибку " Невозможно создание объекта Scripting.FileSystemObject" - вероятно, у меня какие-то проблемы с WSH, т.к. автор пишет, что всё работает "brilliantly".
UPD2: запустил вышеуказанный скрипт на другой машине с Win 7 - ошибки не было, но и эффекта никакого не возымело.
|