Meilleur auteur de réponses
Epinglage de programme dans la barre de tache et bureau Windows 2008R2

Question
-
Bonjour,
Mon problème est simple, mais comme je suis novice, j'ai pas réussi en 12 mois à résoudre le problème.
J'utilise Windows serveur 2008R2 en tant que TSE, j'aimerais ajouter des raccourcis de programme notamment: Firefox, Gadwin printscreen et Irfanview sur le bureau et la barre de tache de chaque utilisateurs. Ces applications sont déjà installé dans le système mais je n'arrive pas à les rendre disponible pour mes utilisateurs TSE pour qu'ils peuvent l’exécuter. J'ai essayé la mauvaise habitude avec Windows serveur 2003 de copier simplement les raccourcis programmes et de les coller vers le dossier quicklaunch dans 'C:\Users\xxx\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar, ou dans 'C:\users\default\Desktop' ou 'C:\users\Public\Bureau Public' mais cela ne fonctionne pas. Je prend toute aide.
Je vous remercie d'avance.
Lauracee
mardi 3 novembre 2015 08:56
Réponses
-
Bonjour,
Pour ceux qui auront ce problème à l'avenir, voici la solution. En fait, pour Windows server 2008R2, l’épinglage de raccourci sur le menu démarrer et la barre de tâche n'est plus possible que grâce au GPO, là j'ignore et c'est tout à fait nouveau pour moi. De plus, j'ai trouvé un bout de code de script en vbs qui l'a fait à épingler les raccourcis à ma place.
1- j'ai crée un GPO dans mon serveur AD par exemple TSE2008
2- j'ai mis là dedans tous les utilisateurs qui vont utiliser le service TSE.
3- j'ai copié les deux scripts ci-dessous dans "C:\Windows\SYSVOL\sysvol\MON_DOMAINE\scripts\TSE2008" de mon serveur AD, le contrôleur de domaine.
et c'est tout, quand l'utilisateur se connecte au serveur TSE, les scripts s'executent, ils sont deux: PinItem.cmd et PinItem.vbs
ci-dessous PinItem.cmd, dans cet exemple, il utilise epingle les applications Office de Microsoft ainsi que l’émulateur de terminal PCOM de IBM. il faut changer 'mon_serveur_AD' par le propre nom de mon contrôleur de domaine.
:: ******************************************************************************** :: Sample command shell script to demonstrate the usage of PinItem.vbs :: ******************************************************************************** :: Source : http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx :: ******************************************************************************** :: Clear all environment variables :: ******************************************************************************** @echo off set ITEM1= set ITEM2= set ITEM3= set ITEM4= set ITEM5= set ITEM6= set ITEM7= set TASKBAR= set USAGE= set PATH= :: ******************************************************************************** :: Set environment variables for PinItem.vbs switch values :: Commemt out a line to not use a switch :: ******************************************************************************** set ITEM11=/item:"%SystemRoot%\System32\ServerManager.msc" set ITEM21=/item:"%SystemRoot%\explorer.exe" set ITEM31=/item:"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" set ITEM1=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\WINWORD.EXE" set ITEM2=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\EXCEL.EXE" set ITEM3=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\OUTLOOK.EXE" set ITEM4=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\POWERPNT.EXE" set ITEM5=/item:"%ProgramFiles(x86)%\Internet Explorer\iexplore.exe" set ITEM6=/item:"%ProgramFiles(x86)%\IBM\Personal Communications\pcsfe.exe" set ITEM7=/item:"%SystemRoot%\explorer.exe" set PATH=\\mon_serveur_AD\netlogon\TSE2008\PinItem.vbs set TASKBAR=/taskbar set STARTMENU=/startmenu set USAGE=/unpin :: ******************************************************************************** :: Execute PinToStartMenu.vbs :: ******************************************************************************** echo on :: ******************************************************************************** :: ******************************************************************************** :: Pin to Taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM1% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM2% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM3% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM4% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM5% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM6% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM7% /taskbar :: ********************************************************************************
ci-desous le PinItem.vbs, je remercie le développeur de ce script dont j'ignore son fonctionnement
'************************************** '* pinitem.vbs ************************ '************************************** ' Windows Script Host Sample Script ' ' ------------------------------------------------------------------------ ' Copyright (C) 2009 Microsoft Corporation ' ' You have a royalty-free right to use, modify, reproduce and distribute ' the Sample Application Files (and/or any modified version) in any way ' you find useful, provided that you agree that Microsoft and the author ' have no warranty, obligations or liability for any Sample Application Files. ' ------------------------------------------------------------------------ '******************************************************************** '* '* File: PinItem.vbs '* Date: 30/07/2012 '* Version: 1.1.0 '* '* Main Function: VBScipt to pin an item to the Start Menu or Taskbar '* '* Usage: cscript PinItem.vbs /item:<path to exe> '* [/taskbar] [/startmenu] [/?] '* [/unpin] '* '* Copyright (C) 2009 Microsoft Corporation '* '* Revisions: '* '* 1.0.0 - 04/03/2008 - Created. '* 1.0.1 - 03/02/2009 - Used Replace in PinItem function to remove "&" '* from verb. '* 1.0.2 - 03/04/2009 - Script name was PinToStartMenu.vbs. Added '* /taskbar switch to pin items to taskbar on '* Win7. '* 1.0.3 - 03/15/2011 - Added /unpin switch to pinitem.vbs script to permit '* unpinning items as well '* 1.1.0 - 30/07/2012 - Added /unpin switch for start menu '* '******************************************************************** '***************************************************************************** '* Declare Variables '***************************************************************************** Option Explicit 'On Error Resume Next Dim blnPinned Dim blnTaskbar Dim blnUnpin Dim i Dim intOpMode Dim objWshShell Dim objFSO Dim objShell Dim strPath Dim strArguments Dim strOptionsMessage Dim blnPin ' Define constants Const CONST_ERROR = 0 Const CONST_WSCRIPT = 1 Const CONST_CSCRIPT = 2 Const CONST_SHOW_USAGE = 3 Const CONST_PROCEED = 4 Const CONST_STRING_NOT_FOUND = -1 Const CONST_FOR_READING = 1 Const CONST_FOR_WRITING = 2 Const CONST_FOR_APPENDING = 8 Const CONST_Success = 0 Const CONST_Failure = 1 Const TRISTATE_USE_DEFAULT = -2 Const TRISTATE_TRUE = -1 'Open the file as Unicode. Const TRISTATE_FALSE = 0 'Open the file as ASCII. blnTaskbar = False blnUnpin = False blnPin = False '***************************************************************************** '* Create Objects '***************************************************************************** Set objWshShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Shell.Application") '******************************************************************** '* Check script host exe and parse command line '******************************************************************** 'Get the command line arguments For i = 0 to Wscript.arguments.count - 1 ReDim Preserve arrArguments(i) arrArguments(i) = Wscript.arguments.item(i) Next 'Check whether the script is run using CScript Select Case intChkProgram() Case CONST_CSCRIPT 'Do Nothing Case CONST_WSCRIPT WScript.Echo "Please run this script using CScript." & vbCRLF & _ "This can be achieved by" & vbCRLF & _ "1. Using ""CScript MODIFYUSERS.vbs arguments"" for Windows 95/98 or" & VbCrLf & _ "2. Changing the default Windows Scripting Host setting to CScript" & vbCRLF & _ " using ""CScript //H:CScript //S"" and running the script using" & vbCRLF & _ " ""MODIFYUSERS.vbs arguments"" for Windows NT." WScript.Quit Case Else WScript.Quit End Select 'Parse the command line Err.Clear() intOpMode = intParseCmdLine(arrArguments, strPath, blnTaskbar, blnPin, blnUnpin, strOptionsMessage) If Err.Number Then Wscript.Echo "Error 0X" & CStr(Hex(Err.Number)) & " occurred in parsing the command line." If Err.Description <> "" Then Wscript.Echo "Error description: " & Err.Description & "." End If 'WScript.quit End If Select Case intOpMode Case CONST_SHOW_USAGE Call ShowUsage() WScript.quit Case CONST_PROCEED 'Do nothing. Case CONST_ERROR WScript.quit Case Else Wscript.Echo "Error occurred in passing parameters." End Select '******************************************************************** '* Main Script '******************************************************************** WScript.Echo strOptionsMessage blnPinned = PinItem(strPath, blnTaskbar, blnUnpin, blnPin) If blnUnpin Then WScript.Echo "Item unpinned: " & CStr(blnPinned) Else WScript.Echo "Item pinned: " & CStr(blnPinned) End If If blnPinned Then WScript.Quit(0) Else WScript.Quit(1) End If '******************************************************************** '* '* Function intChkProgram() '* '* Purpose: Determines which program is used to run this script. '* '* Input: None '* '* Returns: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT, '* and CONST_CSCRIPT. '* '******************************************************************** Private Function intChkProgram() ON ERROR RESUME NEXT Dim i Dim j Dim strFullName Dim strCommand 'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE strFullName = WScript.FullName If Err.Number then Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred." If Err.Description <> "" Then Wscript.Echo "Error description: " & Err.Description & "." End If intChkProgram = CONST_ERROR Exit Function End If i = InStr(1, strFullName, ".exe", 1) If i = 0 Then intChkProgram = CONST_ERROR Exit Function Else j = InStrRev(strFullName, "\", i, 1) If j = 0 Then intChkProgram = CONST_ERROR Exit Function Else strCommand = Mid(strFullName, j+1, i-j-1) Select Case LCase(strCommand) Case "cscript" intChkProgram = CONST_CSCRIPT Case "wscript" intChkProgram = CONST_WSCRIPT Case Else 'should never happen Wscript.Echo "An unexpected program is used to run this script." Wscript.Echo "Only CScript.Exe or WScript.Exe can be used to run this script." intChkProgram = CONST_ERROR End Select End If End If End Function '******************************************************************** '* '* Function intParseCmdLine() '* '* Purpose: Parses the command line. '* '* Input: arrArguments An array containing input from the command line '* '* Input: strPath Path of exe to pin '* strOptionsMessage String containing options selected '* '* Returns: intParseCmdLine is set to one of CONST_ERROR, CONST_SHOW_USAGE, '* and CONST_PROCEED. '* '******************************************************************** Private Function intParseCmdLine(arrArguments, strPath, blnTaskbar, blnPin, blnUnpin, strOptionsMessage) ON ERROR RESUME NEXT Dim i Dim strFlag Dim strSwitchValue strFlag = arrArguments(0) Err.Clear() 'Help is needed If (strFlag = "") OR (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _ OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") OR (strFlag="h") Then intParseCmdLine = CONST_SHOW_USAGE Exit Function End If strOptionsMessage = strOptionsMessage & "" & VbCrLf strOptionsMessage = strOptionsMessage & WScript.ScriptName & VbCrLf strOptionsMessage = strOptionsMessage & "" & VbCrLf strOptionsMessage = strOptionsMessage & "Command Line Options:" & vbCrLf strOptionsMessage = strOptionsMessage & "=======================================" & VbCrLf For i = 0 to UBound(arrArguments) strFlag = Left(arrArguments(i), InStr(1, arrArguments(i), ":")-1) If Err.Number Then 'An error occurs if there is no : in the string Err.Clear Select Case LCase(arrArguments(i)) Case "/q" blnQuiet = True strOptionsMessage = strOptionsMessage & "Supress Console Output: " & blnQuiet & VbCrLf Case "/taskbar" blnTaskbar = True strOptionsMessage = strOptionsMessage & "Pin to Taskbar instead of Start Menu: " & blnTaskbar & VbCrLf Case "/unpin" blnUnpin = True strOptionsMessage = strOptionsMessage & "Unpin instead of Pin: " & blnUnpin & VbCrLf Case "/startmenu" blnPin = True strOptionsMessage = strOptionsMessage & "Pin to Start Menu instead of TaskBar: " & blnPin & VbCrLf Case Else Wscript.Echo arrArguments(i) & " is not recognized as a valid input." intParseCmdLine = CONST_ERROR Exit Function End Select Else strSwitchValue = Right(arrArguments(i), Len(arrArguments(i))-(Len(strFlag)+1)) Select Case LCase(strFlag) Case "/item" strPath = strSwitchValue strOptionsMessage = strOptionsMessage & "Item to pin to Start Menu or Taskbar: " & strPath & VbCrLf Case else Wscript.Echo "Invalid flag " & strFlag & "." Wscript.Echo "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select End If Next If (strPath = "") Then Wscript.Echo "The /item switch is required" Wscript.Echo "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End If intParseCmdLine = CONST_PROCEED End Function '******************************************************************** '* '* Function PinItem() '* '* Purpose: Pin item to the Start Menu. '* '* Input: strlPath Path of exe to pin '* blnTaskbar Pin item to Taskbar instead of Start Menu if true '* '* Dependencies: objShell Shell.Application object '* objFSO File System object '* '* Returns: True if the shortcut is created, else false '* '******************************************************************** Function PinItem(strlPath, blnTaskbar, blnUnpin, blnPin) On Error Resume Next Dim colVerbs Dim itemverb Dim objFolder Dim objFolderItem Dim strFolder Dim strFile If objFSO.FileExists(strlPath) Then '***** Do nothing, folder exists Else '***** Folder does not exist PinItem = False WScript.Echo "File to pin does not exist." WScript.Echo "Please check the input and try again." Exit Function End If strFolder = objFSO.GetParentFolderName(strlPath) strFile = objFSO.GetFileName(strlPath) WScript.Echo "Folder: " & strFolder WScript.Echo "File: " & strFile Err.Clear Set objFolder = objShell.Namespace(strFolder) Set objFolderItem = objFolder.ParseName(strFile) ' ***** InvokeVerb for this does not work on Vista/WS2008 'objFolderItem.InvokeVerb("P&in to Start Menu") ' ***** This code works on Vista/WS2008 Set colVerbs = objFolderItem.Verbs 'arg /taskbar If blnTaskbar Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Épingler à la barre des tâches" Then itemverb.DoIt Next 'arg /taskbar /unpin If blnUnpin Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Détacher de la barre des tâches" Then itemverb.DoIt Next End If End If 'arg /startmenu If blnPin Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Pin to Start Menu" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Épingler au menu Démarrer" Then itemverb.DoIt Next 'arg /startmenu /unpin If blnUnpin Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Unpin from Start Menu" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Détacher du menu Démarrer" Then itemverb.DoIt Next End If End If If Err.Number = 0 Then PinItem = True Else PinItem = False End If End Function '******************************************************************** '* '* Sub ShowUsage() '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages are displayed on screen. '* '******************************************************************** Sub ShowUsage() WScript.Echo "This script is used to Pin items to the Start Menu or Taskbar." WScript.Echo "" WScript.Echo "Usage: cscript " & WScript.ScriptName & " [options]" WScript.Echo "" WScript.Echo "Options:" WScript.Echo "" WScript.Echo " /item:<PathName> Path of item to pin." WScript.Echo "" WScript.Echo " /taskbar Pin to Taskbar instead of Start Menu." WScript.Echo "" WScript.Echo " /startmenu Pin to Start Menu instead of TaskBar." WScript.Echo "" WScript.Echo " /unpin (Optional) Unpin from instead of Pin to." WScript.Echo "" WScript.Echo " /? (Optional) Displays this help text." WScript.Echo "" WScript.Echo "" WScript.Echo "" End Sub
Voilà, c'est tout, j'ai pas fais quelque chose de magique, je ne fais que copier ces codes dans un fichier texte et les renommer respectivement en PinItem.cmd et PinItem.vbs. J'ai renseigner le nom de mon serveur AD (mon CPD) dans le code PinItem.cmd, comme je l'ai mentionné plus haut. Si vous souhaitez epingler plus d'application, vous ne modifierez que le PinItem.cmd, ne touchez pas au PinItem.vbs: vous ajoutez simplement l'instruction SET ITEM8 =, puis renseignez le chemin absolu du programme par exemple SET ITEM8=/item:"%ProgramFiles (x86)%\Foxit Software\Foxit Reader\Foxitreader.exe" pour le lecteur PDF de Foxit Software, puis le dernier modification à ajouter à ce fichier est l'epinglage proprement dit,l'ajout de cette instruction %SystemRoot%\System32\cscript //nologo %PATH% %ITEM8% /taskbar et voilà, pour moi c'est devenu comme un jeux, je m'amuse à ajouter des raccourcis programmes dans la barre de tache de mes utilisateurs TSE2008, alors j'ai pas très compris le fonctionnement de ces deux scritps. JE VOUS REMERCIE pour toutes vos réponses.
- Marqué comme réponse Emile Supiot vendredi 13 novembre 2015 10:51
vendredi 13 novembre 2015 08:02
Toutes les réponses
-
Bonjour Lauracee,
Je vous invite à consulter ce tuto, qui utilise TSE également.
Cordialement,
Emile
Votez! Appel à la contribution TechNet Community Support. LE CONTENU EST FOURNI "TEL QUEL" SANS GARANTIE D'AUCUNE SORTE, EXPLICITE OU IMPLICITE. S'il vous plaît n'oubliez pas de "Marquer comme réponse" les réponses qui ont résolu votre problème. C'est une voie commune pour reconnaître ceux qui vous ont aidé, et rend plus facile pour les autres visiteurs de trouver plus tard la résolution.
mercredi 4 novembre 2015 07:38 -
Bonjour Emile,
Je te remercie beaucoup pour ton post, si claire et rapide. Le TS WebAccess est très intéressant mais ça ne l'est pas pour mon cas, les postes qui vont se connecter à mon serveur TSE sont des clients légers WYSE, je réserve ça pour un dernier recours. Ce que je recherchais SI POSSIBLE, c'est de permettre à mes utilisateurs de lancer une session à distance à partir de ce Wyse, puis une fois connecté, l'utilisateur voit sur son bureau et sa barre de tâche les raccourcis des applications auxquelles ils ont la permission d’exécuter. L'ouverture de session à distance est déjà fait, et fonctionne bien, mais un fois connecté, l'utilisateur ne voit aucun raccourci programme alors que tous ont le droit d’exécuter les applications dans MS Office standard, l'explorateur Windows en cachant le lecteur C:, le navigateur Firefox, Gadwin....
mercredi 4 novembre 2015 11:04 -
Bonjour,
Alors :
le répertoire default si tu le modifie ca ne prendra effet que pour les nouvelles connexions. Celles qui n'ont jamais ete réalisés jusque la sur ton serveur. En gros tu crée un nouveau compte, ca devrait marche pour lui. Sinon, tu as pas un répertoire all user dans c:\documents and settings ?
Tes applications ons bien été installées via le panneau de configuration avec l'option installé une application sur un serveur tse et non pas en double cliquant sur le setup.exe ?
mercredi 4 novembre 2015 16:49 -
Bonjour Matteu,
Merci de ta réponse mais je confirme que ça ne fonctionne toujours pas pour les nouvelles connexions. Pour Windows 2008R2, je crois l'equivalent du repertoire all user est le repertoire Default ou Public car j'ai pas vu de repertoire all user dans le dossier C:\users.
Mes applications sont installés avec l'enchainement des commandes 'change user /install' et 'change user /execute' du console cmd. Je crois qu'ils sont bien installés, je pourrais les exécuter en ouvrant une session localement ou en administrateur de domaine sur le serveur TSE sans avoir de quelconque erreur. Je crois que les sessions à distance pourraient les exécuter aussi à condition que si on met un raccourci de ces programmes sur le bureau ou sur la barre des taches pour pouvoir faire un double clic afin de les exécuter.
Lauracee.
jeudi 5 novembre 2015 08:07 -
Nous utilisons 2008r2 et nous avons dans c:\utilisateurs\public\bureau public les répertoires présents sur tous nos postes dans notre cas donc la je vois plus apres dsl...jeudi 5 novembre 2015 12:43
-
Bonjour Lauracee,
Avez-vous trouvé une solution ?
Cordialement,
Emile
Votez! Appel à la contribution TechNet Community Support. LE CONTENU EST FOURNI "TEL QUEL" SANS GARANTIE D'AUCUNE SORTE, EXPLICITE OU IMPLICITE. S'il vous plaît n'oubliez pas de "Marquer comme réponse" les réponses qui ont résolu votre problème. C'est une voie commune pour reconnaître ceux qui vous ont aidé, et rend plus facile pour les autres visiteurs de trouver plus tard la résolution.
lundi 9 novembre 2015 14:32 -
Bonjour,
Pour ceux qui auront ce problème à l'avenir, voici la solution. En fait, pour Windows server 2008R2, l’épinglage de raccourci sur le menu démarrer et la barre de tâche n'est plus possible que grâce au GPO, là j'ignore et c'est tout à fait nouveau pour moi. De plus, j'ai trouvé un bout de code de script en vbs qui l'a fait à épingler les raccourcis à ma place.
1- j'ai crée un GPO dans mon serveur AD par exemple TSE2008
2- j'ai mis là dedans tous les utilisateurs qui vont utiliser le service TSE.
3- j'ai copié les deux scripts ci-dessous dans "C:\Windows\SYSVOL\sysvol\MON_DOMAINE\scripts\TSE2008" de mon serveur AD, le contrôleur de domaine.
et c'est tout, quand l'utilisateur se connecte au serveur TSE, les scripts s'executent, ils sont deux: PinItem.cmd et PinItem.vbs
ci-dessous PinItem.cmd, dans cet exemple, il utilise epingle les applications Office de Microsoft ainsi que l’émulateur de terminal PCOM de IBM. il faut changer 'mon_serveur_AD' par le propre nom de mon contrôleur de domaine.
:: ******************************************************************************** :: Sample command shell script to demonstrate the usage of PinItem.vbs :: ******************************************************************************** :: Source : http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx :: ******************************************************************************** :: Clear all environment variables :: ******************************************************************************** @echo off set ITEM1= set ITEM2= set ITEM3= set ITEM4= set ITEM5= set ITEM6= set ITEM7= set TASKBAR= set USAGE= set PATH= :: ******************************************************************************** :: Set environment variables for PinItem.vbs switch values :: Commemt out a line to not use a switch :: ******************************************************************************** set ITEM11=/item:"%SystemRoot%\System32\ServerManager.msc" set ITEM21=/item:"%SystemRoot%\explorer.exe" set ITEM31=/item:"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" set ITEM1=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\WINWORD.EXE" set ITEM2=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\EXCEL.EXE" set ITEM3=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\OUTLOOK.EXE" set ITEM4=/item:"%ProgramFiles(x86)%\Microsoft Office\Office14\POWERPNT.EXE" set ITEM5=/item:"%ProgramFiles(x86)%\Internet Explorer\iexplore.exe" set ITEM6=/item:"%ProgramFiles(x86)%\IBM\Personal Communications\pcsfe.exe" set ITEM7=/item:"%SystemRoot%\explorer.exe" set PATH=\\mon_serveur_AD\netlogon\TSE2008\PinItem.vbs set TASKBAR=/taskbar set STARTMENU=/startmenu set USAGE=/unpin :: ******************************************************************************** :: Execute PinToStartMenu.vbs :: ******************************************************************************** echo on :: ******************************************************************************** :: ******************************************************************************** :: Pin to Taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM1% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM2% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM3% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM4% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM5% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM6% /taskbar %SystemRoot%\System32\cscript //nologo %PATH% %ITEM7% /taskbar :: ********************************************************************************
ci-desous le PinItem.vbs, je remercie le développeur de ce script dont j'ignore son fonctionnement
'************************************** '* pinitem.vbs ************************ '************************************** ' Windows Script Host Sample Script ' ' ------------------------------------------------------------------------ ' Copyright (C) 2009 Microsoft Corporation ' ' You have a royalty-free right to use, modify, reproduce and distribute ' the Sample Application Files (and/or any modified version) in any way ' you find useful, provided that you agree that Microsoft and the author ' have no warranty, obligations or liability for any Sample Application Files. ' ------------------------------------------------------------------------ '******************************************************************** '* '* File: PinItem.vbs '* Date: 30/07/2012 '* Version: 1.1.0 '* '* Main Function: VBScipt to pin an item to the Start Menu or Taskbar '* '* Usage: cscript PinItem.vbs /item:<path to exe> '* [/taskbar] [/startmenu] [/?] '* [/unpin] '* '* Copyright (C) 2009 Microsoft Corporation '* '* Revisions: '* '* 1.0.0 - 04/03/2008 - Created. '* 1.0.1 - 03/02/2009 - Used Replace in PinItem function to remove "&" '* from verb. '* 1.0.2 - 03/04/2009 - Script name was PinToStartMenu.vbs. Added '* /taskbar switch to pin items to taskbar on '* Win7. '* 1.0.3 - 03/15/2011 - Added /unpin switch to pinitem.vbs script to permit '* unpinning items as well '* 1.1.0 - 30/07/2012 - Added /unpin switch for start menu '* '******************************************************************** '***************************************************************************** '* Declare Variables '***************************************************************************** Option Explicit 'On Error Resume Next Dim blnPinned Dim blnTaskbar Dim blnUnpin Dim i Dim intOpMode Dim objWshShell Dim objFSO Dim objShell Dim strPath Dim strArguments Dim strOptionsMessage Dim blnPin ' Define constants Const CONST_ERROR = 0 Const CONST_WSCRIPT = 1 Const CONST_CSCRIPT = 2 Const CONST_SHOW_USAGE = 3 Const CONST_PROCEED = 4 Const CONST_STRING_NOT_FOUND = -1 Const CONST_FOR_READING = 1 Const CONST_FOR_WRITING = 2 Const CONST_FOR_APPENDING = 8 Const CONST_Success = 0 Const CONST_Failure = 1 Const TRISTATE_USE_DEFAULT = -2 Const TRISTATE_TRUE = -1 'Open the file as Unicode. Const TRISTATE_FALSE = 0 'Open the file as ASCII. blnTaskbar = False blnUnpin = False blnPin = False '***************************************************************************** '* Create Objects '***************************************************************************** Set objWshShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Shell.Application") '******************************************************************** '* Check script host exe and parse command line '******************************************************************** 'Get the command line arguments For i = 0 to Wscript.arguments.count - 1 ReDim Preserve arrArguments(i) arrArguments(i) = Wscript.arguments.item(i) Next 'Check whether the script is run using CScript Select Case intChkProgram() Case CONST_CSCRIPT 'Do Nothing Case CONST_WSCRIPT WScript.Echo "Please run this script using CScript." & vbCRLF & _ "This can be achieved by" & vbCRLF & _ "1. Using ""CScript MODIFYUSERS.vbs arguments"" for Windows 95/98 or" & VbCrLf & _ "2. Changing the default Windows Scripting Host setting to CScript" & vbCRLF & _ " using ""CScript //H:CScript //S"" and running the script using" & vbCRLF & _ " ""MODIFYUSERS.vbs arguments"" for Windows NT." WScript.Quit Case Else WScript.Quit End Select 'Parse the command line Err.Clear() intOpMode = intParseCmdLine(arrArguments, strPath, blnTaskbar, blnPin, blnUnpin, strOptionsMessage) If Err.Number Then Wscript.Echo "Error 0X" & CStr(Hex(Err.Number)) & " occurred in parsing the command line." If Err.Description <> "" Then Wscript.Echo "Error description: " & Err.Description & "." End If 'WScript.quit End If Select Case intOpMode Case CONST_SHOW_USAGE Call ShowUsage() WScript.quit Case CONST_PROCEED 'Do nothing. Case CONST_ERROR WScript.quit Case Else Wscript.Echo "Error occurred in passing parameters." End Select '******************************************************************** '* Main Script '******************************************************************** WScript.Echo strOptionsMessage blnPinned = PinItem(strPath, blnTaskbar, blnUnpin, blnPin) If blnUnpin Then WScript.Echo "Item unpinned: " & CStr(blnPinned) Else WScript.Echo "Item pinned: " & CStr(blnPinned) End If If blnPinned Then WScript.Quit(0) Else WScript.Quit(1) End If '******************************************************************** '* '* Function intChkProgram() '* '* Purpose: Determines which program is used to run this script. '* '* Input: None '* '* Returns: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT, '* and CONST_CSCRIPT. '* '******************************************************************** Private Function intChkProgram() ON ERROR RESUME NEXT Dim i Dim j Dim strFullName Dim strCommand 'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE strFullName = WScript.FullName If Err.Number then Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred." If Err.Description <> "" Then Wscript.Echo "Error description: " & Err.Description & "." End If intChkProgram = CONST_ERROR Exit Function End If i = InStr(1, strFullName, ".exe", 1) If i = 0 Then intChkProgram = CONST_ERROR Exit Function Else j = InStrRev(strFullName, "\", i, 1) If j = 0 Then intChkProgram = CONST_ERROR Exit Function Else strCommand = Mid(strFullName, j+1, i-j-1) Select Case LCase(strCommand) Case "cscript" intChkProgram = CONST_CSCRIPT Case "wscript" intChkProgram = CONST_WSCRIPT Case Else 'should never happen Wscript.Echo "An unexpected program is used to run this script." Wscript.Echo "Only CScript.Exe or WScript.Exe can be used to run this script." intChkProgram = CONST_ERROR End Select End If End If End Function '******************************************************************** '* '* Function intParseCmdLine() '* '* Purpose: Parses the command line. '* '* Input: arrArguments An array containing input from the command line '* '* Input: strPath Path of exe to pin '* strOptionsMessage String containing options selected '* '* Returns: intParseCmdLine is set to one of CONST_ERROR, CONST_SHOW_USAGE, '* and CONST_PROCEED. '* '******************************************************************** Private Function intParseCmdLine(arrArguments, strPath, blnTaskbar, blnPin, blnUnpin, strOptionsMessage) ON ERROR RESUME NEXT Dim i Dim strFlag Dim strSwitchValue strFlag = arrArguments(0) Err.Clear() 'Help is needed If (strFlag = "") OR (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _ OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") OR (strFlag="h") Then intParseCmdLine = CONST_SHOW_USAGE Exit Function End If strOptionsMessage = strOptionsMessage & "" & VbCrLf strOptionsMessage = strOptionsMessage & WScript.ScriptName & VbCrLf strOptionsMessage = strOptionsMessage & "" & VbCrLf strOptionsMessage = strOptionsMessage & "Command Line Options:" & vbCrLf strOptionsMessage = strOptionsMessage & "=======================================" & VbCrLf For i = 0 to UBound(arrArguments) strFlag = Left(arrArguments(i), InStr(1, arrArguments(i), ":")-1) If Err.Number Then 'An error occurs if there is no : in the string Err.Clear Select Case LCase(arrArguments(i)) Case "/q" blnQuiet = True strOptionsMessage = strOptionsMessage & "Supress Console Output: " & blnQuiet & VbCrLf Case "/taskbar" blnTaskbar = True strOptionsMessage = strOptionsMessage & "Pin to Taskbar instead of Start Menu: " & blnTaskbar & VbCrLf Case "/unpin" blnUnpin = True strOptionsMessage = strOptionsMessage & "Unpin instead of Pin: " & blnUnpin & VbCrLf Case "/startmenu" blnPin = True strOptionsMessage = strOptionsMessage & "Pin to Start Menu instead of TaskBar: " & blnPin & VbCrLf Case Else Wscript.Echo arrArguments(i) & " is not recognized as a valid input." intParseCmdLine = CONST_ERROR Exit Function End Select Else strSwitchValue = Right(arrArguments(i), Len(arrArguments(i))-(Len(strFlag)+1)) Select Case LCase(strFlag) Case "/item" strPath = strSwitchValue strOptionsMessage = strOptionsMessage & "Item to pin to Start Menu or Taskbar: " & strPath & VbCrLf Case else Wscript.Echo "Invalid flag " & strFlag & "." Wscript.Echo "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End Select End If Next If (strPath = "") Then Wscript.Echo "The /item switch is required" Wscript.Echo "Please check the input and try again." intParseCmdLine = CONST_ERROR Exit Function End If intParseCmdLine = CONST_PROCEED End Function '******************************************************************** '* '* Function PinItem() '* '* Purpose: Pin item to the Start Menu. '* '* Input: strlPath Path of exe to pin '* blnTaskbar Pin item to Taskbar instead of Start Menu if true '* '* Dependencies: objShell Shell.Application object '* objFSO File System object '* '* Returns: True if the shortcut is created, else false '* '******************************************************************** Function PinItem(strlPath, blnTaskbar, blnUnpin, blnPin) On Error Resume Next Dim colVerbs Dim itemverb Dim objFolder Dim objFolderItem Dim strFolder Dim strFile If objFSO.FileExists(strlPath) Then '***** Do nothing, folder exists Else '***** Folder does not exist PinItem = False WScript.Echo "File to pin does not exist." WScript.Echo "Please check the input and try again." Exit Function End If strFolder = objFSO.GetParentFolderName(strlPath) strFile = objFSO.GetFileName(strlPath) WScript.Echo "Folder: " & strFolder WScript.Echo "File: " & strFile Err.Clear Set objFolder = objShell.Namespace(strFolder) Set objFolderItem = objFolder.ParseName(strFile) ' ***** InvokeVerb for this does not work on Vista/WS2008 'objFolderItem.InvokeVerb("P&in to Start Menu") ' ***** This code works on Vista/WS2008 Set colVerbs = objFolderItem.Verbs 'arg /taskbar If blnTaskbar Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Épingler à la barre des tâches" Then itemverb.DoIt Next 'arg /taskbar /unpin If blnUnpin Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Détacher de la barre des tâches" Then itemverb.DoIt Next End If End If 'arg /startmenu If blnPin Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Pin to Start Menu" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Épingler au menu Démarrer" Then itemverb.DoIt Next 'arg /startmenu /unpin If blnUnpin Then For each itemverb in objFolderItem.verbs If Replace(itemverb.name, "&", "") = "Unpin from Start Menu" Then itemverb.DoIt If Replace(itemverb.name, "&", "") = "Détacher du menu Démarrer" Then itemverb.DoIt Next End If End If If Err.Number = 0 Then PinItem = True Else PinItem = False End If End Function '******************************************************************** '* '* Sub ShowUsage() '* '* Purpose: Shows the correct usage to the user. '* '* Input: None '* '* Output: Help messages are displayed on screen. '* '******************************************************************** Sub ShowUsage() WScript.Echo "This script is used to Pin items to the Start Menu or Taskbar." WScript.Echo "" WScript.Echo "Usage: cscript " & WScript.ScriptName & " [options]" WScript.Echo "" WScript.Echo "Options:" WScript.Echo "" WScript.Echo " /item:<PathName> Path of item to pin." WScript.Echo "" WScript.Echo " /taskbar Pin to Taskbar instead of Start Menu." WScript.Echo "" WScript.Echo " /startmenu Pin to Start Menu instead of TaskBar." WScript.Echo "" WScript.Echo " /unpin (Optional) Unpin from instead of Pin to." WScript.Echo "" WScript.Echo " /? (Optional) Displays this help text." WScript.Echo "" WScript.Echo "" WScript.Echo "" End Sub
Voilà, c'est tout, j'ai pas fais quelque chose de magique, je ne fais que copier ces codes dans un fichier texte et les renommer respectivement en PinItem.cmd et PinItem.vbs. J'ai renseigner le nom de mon serveur AD (mon CPD) dans le code PinItem.cmd, comme je l'ai mentionné plus haut. Si vous souhaitez epingler plus d'application, vous ne modifierez que le PinItem.cmd, ne touchez pas au PinItem.vbs: vous ajoutez simplement l'instruction SET ITEM8 =, puis renseignez le chemin absolu du programme par exemple SET ITEM8=/item:"%ProgramFiles (x86)%\Foxit Software\Foxit Reader\Foxitreader.exe" pour le lecteur PDF de Foxit Software, puis le dernier modification à ajouter à ce fichier est l'epinglage proprement dit,l'ajout de cette instruction %SystemRoot%\System32\cscript //nologo %PATH% %ITEM8% /taskbar et voilà, pour moi c'est devenu comme un jeux, je m'amuse à ajouter des raccourcis programmes dans la barre de tache de mes utilisateurs TSE2008, alors j'ai pas très compris le fonctionnement de ces deux scritps. JE VOUS REMERCIE pour toutes vos réponses.
- Marqué comme réponse Emile Supiot vendredi 13 novembre 2015 10:51
vendredi 13 novembre 2015 08:02