'Run executable in the same folder via PowerShell
I have a PowerShell script from which I want to run an executable in the same folder:
RunTests.ps1
.\nunitlite-runner.exe
When I right click the script in the Explorer and choose Execute with Powershell I get the following error:
Die Benennung ".\nunitlite-runner.exe" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang. Bei C:\Users\Test\Desktop\MyScripts\RunTests.ps1: 5 Zeichen:23 + .\nunitlite-runner.exe <<<< + CategoryInfo : ObjectNotFound: (.\nunitlite-runner.exe:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Which basically translates to:
The name ". \nunitlite-runner. exe" was not specified as the name of a cmdlet, a function, a script file or an executable program. checking enter the spelling of the name or whether the path is correct (if it contains) and repeat the procedure.
Solution 1:[1]
OK, seems I have found the answer. The problem is not with Powershell or the script. Instead it's with Free Commander.
When I run the script via the context menu, Free Commander seems to not set the working directory correctly (thus the executable is not found). When I run the script via double click, it works just fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Boris |