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
| Option Explicit
Dim URL,Ws,ByPassPSFile,PSFile,MyCmd,Result
Set Ws = CreateObject("wscript.Shell")
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
ByPassPSFile = "cmd /k PowerShell.exe -ExecutionPolicy bypass -noprofile -file "
MyCmd = "$sa = new-object -c shell.application" & VbCrlF
MyCmd = MyCmd & "$path2Notepad = $env:windir" & VbCrlF
MyCmd = MyCmd & "$path2Calc = "& DblQuote("$env:windir\System32") & VbCrlF
MyCmd = MyCmd & "$pn = $sa.namespace($path2Notepad).parsename('notepad.exe')" & VbCrlF
MyCmd = MyCmd & "$pn.invokeverb('taskbarpin')" & VbCrlF
MyCmd = MyCmd & "$pn = $sa.namespace($path2Calc).parsename('calc.exe')" & 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
'********************************************************************************************** |
Partager