[VBS/PowerShell] Pin2TaskBar.vbs
:salut:
Voici une version amélioré qui demande à l'utilisateur de taper le chemin complet de l'application à épingler et le script s'occupera du reste ;)
Exemple si vous voulez épingler ces programmes
Google Chrome :
Citation:
C:\Program Files\Google\Chrome\Application\Chrome.exe
Mozilla Firefox :
Citation:
C:\Program Files\Mozilla Firefox\Firefox.exe
Internet Explorer :
Citation:
C:\Program Files\Internet Explorer\iexplore.exe
TeamViewer :
Citation:
C:\Program Files\TeamViewer\TeamViewer.exe
Skype :
Citation:
C:\Program Files\Skype\Phone\Skype.exe
Microsoft Office :
Citation:
C:\Program Files\Microsoft Office\Office12\WINWORD.EXE
C:\Program Files\Microsoft Office\Office12\EXCEL.EXE
C:\Program Files\Microsoft Office\Office12\POWERPNT.EXE
C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE
C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE
Pin2TaskBar.vbs avec la console DOS visible :king: ;)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Option Explicit
Dim Title,Ws,ByPassPSFile,AppPath,Example,PSFile,MyCmd,Result,MyArray,MyApp,FolderPath,fso
Title = "Pin application into Taskbar on Windows 7 by Hackoo"
Set Ws = CreateObject("wscript.Shell")
Set fso = Createobject("Scripting.FileSystemObject")
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
ByPassPSFile = "cmd /k PowerShell.exe -ExecutionPolicy bypass -noprofile -file "
Example = "C:\windows\system32\calc.exe"
AppPath = InputBox("Enter the path of your application in order to pin it on the taskbar " & vbcr & "Example : " & vbcr & Dblquote(Example) & "",Title,Example)
If AppPath = "" or IsEmpty(AppPath) Then Wscript.Quit()
MyArray = Split(AppPath,"\")
MyApp = MyArray(UBound(MyArray))
FolderPath = fso.GetParentFolderName(AppPath)
MyCmd = "$sa = new-object -c shell.application" & VbCrlF
MyCmd = MyCmd & "$FolderPath = "& DblQuote(FolderPath) & VbCrlF
MyCmd = MyCmd & "$pn = $sa.namespace($FolderPath).parsename('"& MyApp &"')" & VbCrlF
MyCmd = MyCmd & "$pn.invokeverb('taskbarpin')"
Call WriteMyPSFile(MyCmd)
Result = Ws.run(ByPassPSFile & PSFile,1,True)
'**********************************************************************************************
Sub WriteMyPSFile(strText)
Dim fs,ts,PSFile
Const ForWriting = 2
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(PSFile,ForWriting,True)
ts.WriteLine strText
ts.Close
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************************************************************** |
Pin2TaskBar.vbs avec la console DOS invisible :king: :plusser:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Option Explicit
Dim Title,Ws,ByPassPSFile,AppPath,Example,PSFile,MyCmd,Result,MyArray,MyApp,FolderPath,fso
Title = "Pin application into Taskbar on Windows 7 by Hackoo"
Set Ws = CreateObject("wscript.Shell")
Set fso = Createobject("Scripting.FileSystemObject")
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
ByPassPSFile = "Cmd /C PowerShell.exe -ExecutionPolicy bypass -noprofile -file "
Example = "C:\Program Files\Skype\Phone\Skype.exe"
AppPath = InputBox("Enter the path of your application in order to pin it on the taskbar " & vbcr & "Example : " & vbcr & Dblquote(Example) & "",Title,Example)
If AppPath = "" or IsEmpty(AppPath) Then Wscript.Quit()
MyArray = Split(AppPath,"\")
MyApp = MyArray(UBound(MyArray))
FolderPath = fso.GetParentFolderName(AppPath)
MyCmd = "$sa = new-object -c shell.application" & VbCrlF
MyCmd = MyCmd & "$FolderPath = "& DblQuote(FolderPath) & VbCrlF
MyCmd = MyCmd & "$pn = $sa.namespace($FolderPath).parsename('"& MyApp &"')" & VbCrlF
MyCmd = MyCmd & "$pn.invokeverb('taskbarpin')"
Call WriteMyPSFile(MyCmd)
Result = Ws.run(ByPassPSFile & PSFile,0,True)
'**********************************************************************************************
Sub WriteMyPSFile(strText)
Dim fs,ts,PSFile
Const ForWriting = 2
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(PSFile,ForWriting,True)
ts.WriteLine strText
ts.Close
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************************************************************** |
NB : Pour les remerciements pensiez +1 :plusser: :mouarf: