Reputation: 3233
I have an exe file fciv.exe in a folder which i have added to my path variable. I checked it using
$env:Path
But if i just specify the name of the command,
fciv -h
powershell shows the command not found exception.
The same command works in the cmd command prompt.
I have the execution policy set to unrestricted Is there anything else i should do to make it work in Powershell?
EDIT
The relevant lines from output of
Trace-Command Command* {fciv -h} -PSHost
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.ps1 in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.psm1 in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.psd1 in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.COM in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.EXE in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.BAT in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.CMD in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.VBS in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.VBE in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.JS in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.JSE in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.WSF in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.WSH in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.MSC in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.CPL in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandDiscovery Information: 0 : Looking for fciv in "E:\My Software\FCIV"
DEBUG: CommandSearch Information: 0 : WriteLine Current directory results are invalid
DEBUG: CommandSearch Information: 0 : WriteLine Current patterns exhausted in current directory: "E:\My Software\FCIV"
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.ps1 in E:\My Software\AVG\Av
Note that "E:\My Software\FCIV" is the directory where fciv executable file is located.
EDIT 2
Looking at the command trace and seeing that it's looking for fciv.EXE in the right folder but skipping right thorugh, i thought the Upper Case of the extenseion .EXE was the problem so i tried adding .exe to the PATHEXT variable
Now it looks for fciv.exe in the correct folder but still skips right through it and says it has exhausted current patterns in the current directory.
EDIT 3
I have figured it out, it seems that in my PATH environment variable
"E:\My Software\FCIV"
appeared within double quotes while, no other directory was. Command Prompt cmd was able to work despite this however powershell is not, i don't see why but i am glad i at least found out how to solve the problem.
Upvotes: 2
Views: 1346
Reputation: 2413
Note: You have updated your question with an answer, but it's nice to have an actual answer posted.
In your debug trace you get lines like the following:
DEBUG: CommandDiscovery Information: 0 : Looking for fciv.ps1 in "E:\My Software\FCIV"
The path is "E:\My Software\FCIV"
when it should be E:\My Software\FCIV
.
This indicates your path is incorrectly set, and this item is quoted in your path when it does not need to be.
Here is an excerpt of an example trace from then I run iexplore.exe:
DEBUG: CommandDiscovery Information: 0 : Looking for iexplore.exe.* in C:\Program Files (x86)\Internet Explorer
DEBUG: CommandSearch Information: 0 : WriteLine Next path found: C:\Program Files (x86)\Internet Explorer\iexplore.exe
DEBUG: CommandDiscovery Information: 0 : Command Found: path (C:\Program Files (x86)\Internet Explorer\iexplore.exe) is an application with name: iexplore.exe
Note that the paths are not quoted and it found the executable.
Upvotes: 1