powershell - How to PIN MSEdge to taskbar with batch file -


i'm trying pin/unpin microsoft edge taskbar using batch file. have several hundred computers to, attempting make batch / powershell / vbscript unpin instances of edge taskbar, , pin 1 single instance taskbar way can sure pinned once. can point me in right direction?

this answer from: http://rolfsnotepad.blogspot.com.au/2016/06/unpin-edge-and-pin-internet-explorer.html

i have tested pin ie , works:

# apps array holds hash tables information each app should pinned.  # each hash table has name of app, 2 byte arrays , strings various settings  # app's shortcut. registryentry byte array contains bytes need  # inserted favorites registry key, while matchstring byte array used check  # if app pinned. # # if accidentally end pinning app pinned, existing taskbar  # entry break. reason, matchstring should subset of registryentry # not change between computers or versions of app.  cls  $apps = @( @{ "appname" = "microsoft internet explorer" "registryentry" = @(0,170,1,0,0,58,0,31,128,200,39,52,31,16,92,16,66,170,3,46,228,82,135,214,104,38,0,1,0,37,0,239,190,18,0,0,0,118,241,189,129,21,120,209,1,16,214,92,131,21,120,209,1,16,214,92,131,21,120,209,1,20,0,86,0,49,0,0,0,0,0,182,72,114,151,17,0,84,97,115,107,66,97,114,0,64,0,9,0,4,0,239,190,103,72,105,16,182,72,114,151,46,0,0,0,147,77,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,154,101,231,0,84,0,97,0,115,0,107,0,66,0,97,0,114,0,0,0,22,0,24,1,50,0,43,5,0,0,103,72,103,16,32,0,73,78,84,69,82,78,126,49,46,76,78,75,0,0,170,0,9,0,4,0,239,190,176,72,131,85,182,72,114,151,46,0,0,0,143,221,1,0,0,0,7,0,0,0,0,0,0,0,0,0,90,0,0,0,0,0,156,250,31,0,73,0,110,0,116,0,101,0,114,0,110,0,101,0,116,0,32,0,69,0,120,0,112,0,108,0,111,0,114,0,101,0,114,0,46,0,108,0,110,0,107,0,0,0,64,0,67,0,58,0,92,0,87,0,105,0,110,0,100,0,111,0,119,0,115,0,92,0,83,0,121,0,115,0,116,0,101,0,109,0,51,0,50,0,92,0,105,0,101,0,52,0,117,0,105,0,110,0,105,0,116,0,46,0,101,0,120,0,101,0,44,0,45,0,55,0,51,0,49,0,0,0,28,0,82,0,0,0,29,0,239,190,2,0,77,0,105,0,99,0,114,0,111,0,115,0,111,0,102,0,116,0,46,0,73,0,110,0,116,0,101,0,114,0,110,0,101,0,116,0,69,0,120,0,112,0,108,0,111,0,114,0,101,0,114,0,46,0,68,0,101,0,102,0,97,0,117,0,108,0,116,0,0,0,28,0,0,0) "matchstring" = @(77,0,105,0,99,0,114,0,111,0,115,0,111,0,102,0,116,0,46,0,73,0,110,0,116,0,101,0,114,0,110,0,101,0,116,0,69,0,120,0,112,0,108,0,111,0,114,0,101,0,114,0,46,0,68,0,101,0,102,0,97,0,117,0,108,0,116) "shortcutpath" = "\microsoft\internet explorer\quick launch\user pinned\taskbar\internet explorer.lnk"  "shortcutwildcardpath" = "\microsoft\internet explorer\quick launch\user pinned\taskbar\internet explorer*.lnk" "shortcuttargetpath" = "c:\program files\internet explorer\iexplore.exe"  "shortcutworkingdirectory" = "%homedrive%%homepath%"  } )  # start assumption no apps pinned.  $atleastoneappwasnotpinned = $false  foreach ($app in $apps)  {      $currentappwasnotpinned = $true      # save current value of taskbar registry key byte array     $currenttaskbar = (get-itemproperty -path "hkcu:\software\microsoft\windows\currentversion\explorer\taskband" -name "favorites").favorites # save last index current taskbar array , matchstring array.      $currenttaskbarlastindex = ($currenttaskbar.length - 1)      $matchstringlastindex = ($app["matchstring"].length - 1)      # used keep track of current location in byte arrays      $matchstringcurrentindex = 0     $currenttaskbarcurrentindex = 0      # loop through current taskbar array      while ($currenttaskbarcurrentindex -lt $currenttaskbarlastindex)     {          if ($currenttaskbar[$currenttaskbarcurrentindex] -eq $app["matchstring"][$matchstringcurrentindex])          {              # if current value of registry byte array matches first value of app byte array,              # save current registry byte array index.             $startindex = $currenttaskbarcurrentindex              # proceed compare next item in registry byte array next value in              # matchstring byte array until no longer match, greedy regex.              while ($currenttaskbar[$currenttaskbarcurrentindex] -eq $app["matchstring"][$matchstringcurrentindex])              {                 # if got match on entire matchstring, current app pinned.                  if ($matchstringcurrentindex -eq $matchstringlastindex)                  {                      $currentappwasnotpinned = $false                  }                  $matchstringcurrentindex += 1                  $currenttaskbarcurrentindex += 1              }              # reset app byte array index counter              $matchstringcurrentindex = 0              # move registry byte array index location of match caused enter # if block.             $currenttaskbarcurrentindex = $startindex          }          # step next byte in registry array          $currenttaskbarcurrentindex += 1      }      if ($currentappwasnotpinned -or ($currenttaskbarlastindex -eq 0))      {          $atleastoneappwasnotpinned = $true          # various reasons end having shortcut in taskbar directory if app # shortcut points isn't pinned.          #to make sure such shortcuts won't cause # issues, remove them.          remove-item ((get-childitem env:appdata).value + $app["shortcutwildcardpath"]) # create app's shortcut in taskbar directory.          $taskbarshortcutpath = (get-childitem env:appdata).value + $app["shortcutpath"]         $wshshell = new-object -comobject wscript.shell         $shortcut = $wshshell.createshortcut($taskbarshortcutpath)          $shortcut.targetpath = $app["shortcuttargetpath"]         $shortcut.workingdirectory = $app["shortcutwildcardpath"]         $shortcut.save()          # add app's byte array current taskbar registry entry.          $taskbar = $app["registryentry"] + $currenttaskbar          # overwrite existing taskbar registry key version has current app pinned.          new-itemproperty -path "hkcu:\software\microsoft\windows\currentversion\explorer\taskband" -name "favorites" -value $taskbar -propertytype binary -force | out-null     }  }  if ($atleastoneappwasnotpinned)  {      write-output "at least 1 app not pinned, pinning , restarting explorer.exe refresh taskbar."     # restart explorer refresh taskbar      invoke-expression "taskkill /f /im explorer.exe"      invoke-expression "start explorer.exe"  }  else  {     write-output "all apps pinned."  } 

Comments