shorter/cleaner way of writing this
I'm wondering if there's a nicer way of looking for vlc's uninstaller executable in both 'program files' and 'program files (x86)'. At the moment I've defined the expected location of the executable but it seems a bit static.
$VLC_Uninstall = @(
'C:\Program Files (x86)\VideoLAN\VLC\uninstall.exe',
'C:\Program Files\VideoLAN\VLC\uninstall.exe'
)
Foreach ($uninstall in $VLC_Uninstall) {
if (test-path $uninstall) {
#do uninstall using $uninstall
}
}
Posted Jun 20, 2017, 12:50 PM UTC · edited
You've got this about as clean as you can get. One thing, you've got a comma after the 2nd entry in the $VLC_Uninstall array, which will throw an error when you try to make the declaration.
ah yes initially I had a third entry in there which I removed and forgot about that extra comma.