4 ms·
Sometimes I just want to open a shell and run an exe. With powershell you need to run a command which runs the application. I gave up after that. https://stacko
by rb808 9y ago
Sometimes I just want to open a shell and run an exe. With powershell you need to run a command which runs the application. I gave up after that. https://stackoverflow.com/questions/1673967/how-to-run-an-exe-file-in-powershell-with-parameters-with-spaces-and-quotes https://stackoverflow.com/questions/1673967/how-to-run-an-ex...
- randomString1 9y agoWhat's wrong with .\example.exe? Or .example.exe, .$exampleWithPath for PS1 files? Just examples that I see in the wild
- rb808 9y agoDidn't work for me, I think you have to prepend with a & so & notepad.exe Which isn't complicated I agree but annoyed me.
- AnIdiotOnTheNet 9y agoWhat version of Powershell are you using? Just typing "notepad" is enough to launch it. The problems with powershell and executables only really come in to play when argument passing, where some escaping is necessary.
- rb808 9y ago3, we still have win7 at work.
- joeyaiello 9y agoYou can download and install PowerShell Core 6 completely side-by-side with Windows PowerShell 3.0. We even have a portable ZIP you can drop down wherever: https://github.com/powershell/powershell/releases https://github.com/powershell/powershell/releases
- Arnavion 9y agoThe only reason to use iex is if the thing you're trying to execute is not directly the name of the process. So you need & for `&'notepad'` and `&$string_variable` but not `notepad`
- gecko 9y agoThat's not quite correct (and neither is that StackOverflow answer). If you want to execute the EXE stored in a variable or whatnot, then yes, you need `&`, which I think is borrowed from Perl. But otherwise, the rules in PowerShell are the same as a Unix shell: if it's in the PATH, just type the command name (with or without the .exe); otherwise, use the full path.
- Arnavion 9y ago>That's not quite correct (and neither is that StackOverflow answer). The SO answer isn't wrong. The EXE there has a space in the path. The answer uses a string literal for it and thus needs &. It could of course escape the spaces with ` instead; then it wouldn't need a string literal and thus not need &.