The power shell cannot use basic commands

布布子 21 Reputation points
2022-12-19T02:24:55.957+00:00

System: windows11

When I execute a command in powershell, I cannot use it;
For example, 'ping','java','nodejs'

I can execute it correctly in CMD.
I'm sure it's already added to the 'path' variable.

But it still won't execute in powershell.
Display 'ping is not recognized as an internal or external command'

It worked a long time ago,I'm not sure what configuration I changed.
I tried to reinstall powershell, but it didn't work.

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. !Daniel Bradley 1,066 Reputation points MVP
    2022-12-19T06:24:50.427+00:00

    Hey @布布子

    It sounds like you may need to update the PATH variable

    Go to Properties in My computer, Advanced system settings → Advanced → Environment Variables Select 'PATH' from the list of system variables and edit and set PATH to c:\windows\system32 ; this will solve your problem

    Otherwise, I would recommend uninstalling and re-installing PowerShell.

    Control Panel > Uninstall a program > Turn Windows features on or off > fine Windows Powershell and uncheck. Restart your PC and follow the same process to re-install.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2022-12-19T16:12:34.617+00:00

    Hello,

    Indeed it may look like a wrong environmental variable. Try the next:

    1.Search for "environment variables" in the Windows search bar and open the respective Control Panel item.
    2.A System Properties window will appear. Click on "Environment Variables" at the bottom.
    3.Edit the PATH environment variable and add the path to the folder where where the sources are located is located. (for example for Ping, should be C:/Windows/System32


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.