Guest User

Untitled

a guest
Mar 26th, 2020
157
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # https://github.com/farag2/Windows-10-Setup-Script
  2.  
  3. # Pin the shortcuts to Start
  4. # Download syspin.exe to the "Downloads" folder
  5. # http://www.technosys.net/products/utils/pintotaskbar
  6. # SHA256: 6967E7A3C2251812DD6B3FA0265FB7B61AADC568F562A98C50C345908C6E827
  7. $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
  8. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  9. $param = @{
  10.     Uri = "http://www.technosys.net/download.aspx?file=syspin.exe"
  11.     OutFile = "$DownloadsFolder\syspin.exe"
  12.     Verbose = [switch]::Present
  13. }
  14. Invoke-WebRequest @param
  15. Add-Type -AssemblyName System.Windows.Forms
  16. $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
  17. $OpenFileDialog.InitialDirectory = $DownloadsFolder
  18. $OpenFileDialog.Filter = "*.exe|*.exe|All Files (*.*)|*.*"
  19. # Focus on open file dialog
  20. $tmp = New-Object System.Windows.Forms.Form -Property @{TopMost = $true}
  21. $OpenFileDialog.ShowDialog($tmp)
  22. if ($OpenFileDialog.FileName)
  23. {
  24.     # Pin "Control Panel" to Start
  25.     $Items = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
  26.     $ControlPanelLocalizedName = ($Items | Where-Object -FilterScript {$_.Path -eq "Microsoft.Windows.ControlPanel"}).Name
  27.     # Check whether the Control Panel shortcut was ever pinned
  28.     if (Test-Path -Path "$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk")
  29.     {
  30.         $Arguments = @"
  31.             "$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk" "51201"
  32. "@
  33.         Start-Process -FilePath $OpenFileDialog.FileName -WindowStyle Hidden -ArgumentList $Arguments -Wait
  34.     }
  35.     else
  36.     {
  37.         # The "Pin" verb is not available on the control.exe file so the shortcut has to be created
  38.         $shell = New-Object -ComObject Wscript.Shell
  39.         $shortcut = $shell.CreateShortcut("$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk")
  40.         $shortcut.TargetPath = "$env:SystemRoot\System32\control.exe"
  41.         $shortcut.Save()
  42.         $Arguments = @"
  43.             "$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" "51201"
  44. "@
  45.         Start-Process -FilePath $OpenFileDialog.FileName -WindowStyle Hidden -ArgumentList $Arguments -Wait
  46.         Remove-Item -Path "$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" -Force
  47.     }
  48.     # Pin "Devices and Printers" to Start
  49.     # Create old style shortcut for the "Devices and Printers" in the Start menu
  50.     $DevicesAndPrintersLocalizedName = (Get-ControlPanelItem | Where-Object -FilterScript {$_.CanonicalName -eq "Microsoft.DevicesAndPrinters"}).Name
  51.     $shell = New-Object -ComObject Wscript.Shell
  52.     $shortcut = $shell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\$DevicesAndPrintersLocalizedName.lnk")
  53.     $shortcut.TargetPath = "control"
  54.     $shortcut.Arguments = "printers"
  55.     $shortCut.IconLocation = "$env:SystemRoot\system32\DeviceCenter.dll"
  56.     $shortcut.Save()
  57.     # Pause for 3 sec, unless the "Devices and Printers" shortcut won't dispalyed in the Start menu
  58.     Start-Sleep -Seconds 3
  59.     $Arguments = @"
  60.         "$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\$DevicesAndPrintersLocalizedName.lnk" "51201"
  61. "@
  62.     Start-Process -FilePath $OpenFileDialog.FileName -WindowStyle Hidden -ArgumentList $Arguments -Wait
  63.     # Pin "Command Prompt" to Start
  64.     $Arguments = @"
  65.         "$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\Command Prompt.lnk" "51201"
  66. "@
  67.     Start-Process -FilePath $OpenFileDialog.FileName -WindowStyle Hidden -ArgumentList $Arguments -Wait
  68. }
  69. # Delete downloaded syspin.exe
  70. Remove-Item -Path "$DownloadsFolder\syspin.exe" -Force
  71. # Restart the Start menu
  72. Stop-Process -Name StartMenuExperienceHost -Force
RAW Paste Data