Author Posts

February 15, 2018 at 10:43 pm

I have (what I think is) a bit of weird case
That turned out to be hard to google

For some reason, powershell, wont properly execute windows commands that are on my path (like for example compilers)
unless i type their name.extension

So for example, I install the rust compiler, so if I type

cargo

I get the error commnd not found:

cargo : The term 'cargo' is not recognized as the name of a cmdlet, function, script file, or operable program.

But if i type

cargo.exe

the command does get executed, but it gets executed as if in sub-process, so it does get executed in-line in my shell
it pops a new windows, where it executes the command and close rapidly

Weirdness doesnt stop here
I have another account with admin privilige, this one works fine, I dont have this issue

Also i checked the $env:path variable, it is fine, and again proof of this, is that cargo.exe does .. kinda .. work

Is there a setting, that I changed for some reason, and forgot about that is causing this behavior

February 15, 2018 at 11:03 pm

I cannot think of any setting off the top of my head, you could have done on purpose / by accident, via the Console Host, ISE or VSCode terminal that would cause what you are seeing.

However, if you are using external commands, you really need to add the extension (in most cases a .exe) to avoid any confusion about what you are trying to run.

Also, in general they must approach a specific way. Here are two articles on the topic.

Using PowerShell and external commands and their parameters or switches.

'social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx'

'edgylogic.com/blog/powershell-and-external-commands-done-right'

'blogs.technet.microsoft.com/josebda/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters'

February 16, 2018 at 4:41 am

thanks for the links
but i dont think they match my case

i know that calling windows commands, was working before, but suddenly it stopped
i must have set something

but as i say, what is weird, is that on the same machine, the user with admin privilige work fine
this is why i dont think it can be because i have installed something
because it would have been the same problem for all users on my computer

February 16, 2018 at 3:23 pm

So, this fail is when you are calling your commands from the console host, the ISE or in VSCode?

You can run code in the console host and the ISE to reset them back to their defaults to see if that resolves you issues.

You can get the default settings from any other machine, and use that to reset yours.

If you are using profiles in each, either remove them, are start PoSH using the -noprofile parameter.

February 16, 2018 at 10:49 pm

PS C:\Users\...\bin> Test-Path $profile
False

it seems i dont even have a profile set, for this to be possibly a settings issues

February 17, 2018 at 12:45 am

More updates

I installed powershell 6
And I am getting almost the same behavior

windows command wont execute, with my none admin account, unless i add the .exe part
some command such as ping, i cant figure a way to execute them (ping.exe wont work for example)

pwsh6 is only different from powershell 5 in that windows command (after i added their extension) will execute in
the current shell, on powershell 5, they pop-up a new shell windows

again, to be clear, my account with admin privileges works fine

February 17, 2018 at 3:19 pm

Guys

it fixed itself, or i fixed it, i have no clue
but i uninstalled Idera Powershell Plus, and then restarted the computer

the computer also coincidentally installed some windows updates

but now i no longer have this issue
i think that idera powershell plus, might have been it .. but .. again
cannot be 100% sure