Skip to content

Instantly share code, notes, and snippets.

@abergs
Created August 6, 2014 22:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abergs/6029a4f36673aaa3ba79 to your computer and use it in GitHub Desktop.
Save abergs/6029a4f36673aaa3ba79 to your computer and use it in GitHub Desktop.
Powershell Launcher
$paths = "$env:APPDATA\Microsoft\Internet Explorer\Quick Launch", "C:\ProgramData\Microsoft\Windows\Start Menu", "$env:APPDATA\Microsoft\Windows\Start Menu"
$searchword =$args[0]
$otherargs = $args[1..100]
Write-Host $otherargs
foreach ($path in $paths) {
$applications = Get-ChildItem $path -recurse -File -Filter $searchword*
$applicationPath = @($applications | ForEach-Object -Process {$_.FullName})
#Write-host $applications
#write-host "-----"
if($applications.length -eq 0) {Continue}
if($applications.length -eq 1) {
$firstapp = $applicationPath
}
else {
$firstapp = $applicationPath[0]
}
#write-host $firstapp
if($otherargs.length -eq 0) {
start-process $firstapp
break
}else {
start-process $firstapp $otherargs
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment