I am trying to run an executable from inside of a container from Power Shell and get an error message that it could not be found. However I've confirmed its directory is in Path and the executable is where I expect it to be. What am I missing?
PS C:\work\some_project> docker run -it --rm --name="iar_build" iar_env
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\docker_work> IarBuild.exe
IarBuild.exe : The term 'IarBuild.exe' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ IarBuild.exe
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (IarBuild.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\docker_work> $Env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\
OpenSSH\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\IAR Systems\Embedded
Workbench 8.1\common\bin"
PS C:\docker_work> ls 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\common\bin\IarBuild.exe'
Directory: C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\common\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 9/1/2018 4:09 AM 724992 IarBuild.exe
PS C:\docker_work>
My docker file contains the following:
...
# Add the IAR common\bin\ folder to the image's PATH
RUN setx path \
"%path%;C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\common\bin\"
...
CMD [ "powershell.exe", "-executionpolicy" , "Unrestricted" ]
You will need to add a .\ so it will look like .\IarBuild.exe as it is currently trying to process the .exe as a cmdlet
Edit: If you start to type the name of the exe and press Tab it will autocomplete to .\IarBuild.exe if not type in manually
Hope that helps
Related
I have a problem about running sh file in Intellij in Windows.
When I clicked the run button in the file, I got this output shown below.
PS C:\Users\username\IdeaProjects\library> /bin/sh C:/Users/username/IdeaProjects/library/aws-setup.sh
/bin/sh : The term '/bin/sh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify t
hat the path is correct and try again.
At line:1 char:1
+ /bin/sh C:/Users/username/IdeaProjects/library/aws-setup.sh
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (/bin/sh:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How can I fix it?
Set Settings (Preferences on macOS) | Tools | Terminal | Shell path to c:\Program Files\Git\bin\bash.exe or use Shell Script run configuration with Interpreter path set to bash.exe:
This is the exact error on the cmd window.
this is the command I typed to be executed in the cmd
F:\Fast R-CNN\Cognitive tool kit\cntk\Scripts\install\windows>install.bat
CNTK Binary Install Script
F:\Fast : The term 'F:\Fast' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ F:\Fast R-CNN\Cognitive tool kit\cntk\Scripts\install\windows\ps\inst ...
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (F:\Fast:String) [], CommandNotF
oundException
+ FullyQualifiedErrorId : CommandNotFoundException
Error during install operation
I've tried running as admin, direct clicking, changing the path etc. Kindly tell me a way to run this file. It's a batch file for a series of installations for the Microsoft cognitive tool kit.
Looks like you need to enclose the path in quotes
"F:\Fast R-CNN\Cognitive tool kit\cntk\Scripts\install\windows\install.bat"
use "start" before the filename.
Example:
F:\Fast R-CNN\Cognitive tool kit\cntk\Scripts\install\windows>start install.bat
Powershell suddenly quit opening from both cmd and powershell prompts. I haven't installed anything new between when it did work and when it quit working.
When I try to start powershell.exe from a cmd window (both elevated and not elevated) with the following command
C:\Users\myuser>powershell.exe
I get a popup error from the OS that says:
This app can't run on your PC
Once I close that popup the cmd prompt I made the call from then prints:
Access is denied
To the screen (yes even when I do this in an elevated cmd prompt)
When I try to do it in powershell with the following command:
PS C:\Users\myuser> powershell.exe
I get:
Program 'powershell.exe' failed to run: The specified executable is not a valid application for this OS platform.
At line:1 char:1
+ powershell.exe
+ ~~~~~~~~~~~~~~.
At line:1 char:1
+ powershell.exe
+ ~~~~~~~~~~~~~~.
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorID : NativeCommandFailed
Apparently even powershell doesn't like powershell anymore.
I've tried restarting the computer and that didn't fix it, but I'm totally stymied as to what to do next.
#PetSerAl gave the crucial pointer in comments on the question.
The "This app can't run on your PC" pop-up error message on Windows 8 or above
indicates:
a corrupted file, such as a 0-byte *.exe file, esp. when followed by an "Access denied" error in the console.
or, increasingly less commonly, an attempt to run a 64-bit executable on a 32-bit edition of Windows.
Troubleshooting steps:
From a Command Prompt (cmd.exe console), run where.exe <executable-name>;
from PowerShell, run Get-Command -All <executable-name>, which shows you all executables by that name present in the directories listed in the $env:PATH environment variable in that order, by their full paths.
Note that where.exe, unlike Get-Command, also looks in the current directory, and looks there first.
Thus, the first path returned is the executable that is actually executed when only the executable name is specified.
Note that a match in the current directory, if found by where.exe, only matters when calling the executable from cmd.exe (from the Command Prompt or a batch file), because PowerShell by design doesn't allow invocation of executables from the current directory by mere name.
If you want to run where.exe from PowerShell, extension .exe is required, because the command name where by itself is a built-in alias for the Where-Object cmdlet.
In the output from where.exe / Get-Command, check:
if the executable you expect is listed first.
if its size is non-zero.
Remove unexpected (zero-byte) executables, or, if you expect them to be there as functioning executables, reinstall them.
Example:
Look for all all executables named powershell.exe in the current directory and in the directories listed in $env:PATH.
Note that the proper home of powershell.exe is C:\Windows\System32\WindowsPowerShell\v1.0, as reflected in $PSHOME.
From cmd.exe (regular Command Prompt):
where powershell.exe
Example output:
C:\Windows\System32\powershell.exe
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
From PowerShell:
Get-Command -All powershell.exe
If you also want to look in the current directory, use
Get-Command -All .\powershell.exe, powershell.exe
Example output:
CommandType Name Version Source
----------- ---- ------- ------
Application powershell.exe 0.0.0.0 C:\WINDOWS\system32\powershell.exe
Application powershell.exe 10.0.14... C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
If you want to include the file size in the output:
PS> where.exe powershell.exe | % { [system.io.fileinfo] $_ |
select fullname, length, #{ n = 'Version'; e = { $_.versioninfo.FileversionRaw } } }
FullName Length Version
-------- ------ -------
C:\Windows\System32\powershell.exe 0
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 446976 10.0.14393.206
Delete the powershell.exe (with 0KB) from location C:\Windows\System32
In my case Powershell working fine after deleting the powershell.exe (with 0KB) from system 32
The term 'jmeter' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
jmeter -n -t D:\apache-jmeter-2.13\apache-jmeter-
2.13\bin\zzz\zzz ...
~~~~~~
CategoryInfo : ObjectNotFound: (jmeter:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
Use 'cmd' instead of the Powershell console. Also may sure that you have Jmeter(folder installation)\bin in your PATH environment variable.
If you are on Windows 10 and using Windows PowerShell make sure you are inside JMeter's bin folder and start your command with .\jmeter instead of only jmeter.
.\jmeter -n -t D:\apache-jmeter-2.13\apache-jmeter- 2.13\bin\zzz\zzz ...
I was using PowerShell normally (was using posh git, just to mention), and suddenly a weird behavior happened, I tried to restart the session, when I did, I got many errors, which are :
Split-Path : The term 'Split-Path' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:1 char:16
+ Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -P ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Split-Path:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Import-Module : The specified module '.\posh-git' was not loaded because no valid module file was found in any module directory.
At C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:4 char:1
+ Import-Module .\posh-git
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (.\posh-git:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Enable-GitColors : The term 'Enable-GitColors' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:26 char:1
+ Enable-GitColors
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-GitColors:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Pop-Location : The term 'Pop-Location' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:28 char:1
+ Pop-Location
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Pop-Location:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Start-SshAgent : The term 'Start-SshAgent' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:30 char:1
+ Start-SshAgent -Quiet
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Start-SshAgent:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here's a picture of that :
I tried to restart the PC, but still have the same problem every time I start a new PowerShell session, I noticed that many commands don't work, what caused this problem ? and what should I do to solve it ?
Update
I removed the profiles added by PoshGit, when starting a new session, I don't have any error, but powershell still doesn't recognize commands, for example calling Clear-host, throws lots of errors that I can't understand the cause !
You're PSModulePath system environment varaible is missing C:\windows\system32\WindowsPowerShell\v1.0\Modules which is the location of all "system"/built-in modules in PowerShell.
Something you've installed (posh git maybe?) has probably messed it up. Add it to the system variable.
The easiest way to do it without PowerShell is using the GUI as described here:
http://www.computerhope.com/issues/ch000549.htm
If you just installed posh-git it added some Powershell profile files, basically some .ps1 files executed each time a powershell session starts.
Just remove (or fix) them; from the path in the errors thrown probably they are in C:\Users\aymen.daoudi\Documents\WindowsPowerShell\...
I had a similar shell error message when loading my profile after installing posh-git ... profile.example.ps1 is not recognized as the name of a cmdlet.
This happened to me when I copied over files to my user directory from an older machine - the older poshgit powershell user profiles came along with it.
The fix for me was to rename the old posh-git profile from the path below...
Original Profile Path
C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
New Profile Name
C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.notused
After choco uninstall poshgit and choco install poshgit a new profile was created with the right data (went from 5KB to 1KB in size).