More powershell madness

I keep all my small utilities (gnu stuff, tcpview, process explorer and more) in a separated folder, so I can sync them a cloud service. The problem is that every time I want to access any of these tools, I need to navigate to that folder. I made this script in Powershell to collect all *.exe filenames and create a shortcut to each of them in a destination folder, that way we can keep all shortcuts at once in the start menu 🙂

 

$destDir="$($env:APPDATA)\Microsoft\Windows\Start Menu\Programs\MyUtilities"
$executablesRootPath="c:\MyAppsPath"
New-Item -ItemType Directory -Force -Path $destDir
$executablesDir = get-childitem $executablesRootPath -recurse
$executables = $executablesDir | where {$_.extension -eq ".exe"}
Foreach ($executable in $executables) {
  $shortName=$executable.Name.Replace(".exe", ".lnk")
  $shortcutPath="$($destDir)\$($shortName)"
  $ws = New-Object -ComObject WScript.Shell
  $newShortCut = $ws.CreateShortcut($shortcutPath)
  $newShortCut.TargetPath = $executable.FullName
  $newShortCut.Save()
}