Created
August 6, 2014 22:12
-
-
Save abergs/6029a4f36673aaa3ba79 to your computer and use it in GitHub Desktop.
Powershell Launcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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