-1

When I run the lnk_change.bat file to execute the lnk_change.ps1 windows script, then on the command line it says PowerShell.exe is not an internal or external command executable program or batch file. Please help me solve this problem.Win 10 home

bat file content:@ECHO OFF PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "&'%~dpn0.ps1'" PAUSE

I tried to add the file to the environment variables but it did not help (

  • 2
    Powershell is not in your path. Either from START add the Path using "Edit Environmental Variables for you Account" or use PS full path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe – jdweng Aug 18 '23 at 12:08
  • 1
    Note that `powershell.exe` _should_ be in your PATH by default, so something unusual is going on on your machine. – mklement0 Aug 18 '23 at 13:06
  • 2
    Does this answer your question? [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/questions/41454769/what-is-the-reason-for-x-is-not-recognized-as-an-internal-or-external-command) The __system__ environment variable `Path` begins by Windows default with `%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\;` It looks like this is not the case on your computer or in the __local__ execution environment of `cmd.exe` on processing the batch file. – Mofi Aug 18 '23 at 13:39
  • I recommend to run in the command prompt window `set PATH` (__local__ `PATH` and `PATHEXT`) and `%SystemRoot%\System32\reg.exe QUERY HKCU\Environment /v Path` (__user__ `PATH`) and `%SystemRoot%\System32\reg.exe QUERY "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v Path` (__system__ `PATH`), [copy the output](https://stackoverflow.com/questions/11543578/), [edit] your question, paste the copied text, reselect the pasted text and pressing __Ctrl+K__ or clicking in toolbar on the symbol __{ }__ for formatting the text as preformatted text. Then we may be able to help you. – Mofi Aug 18 '23 at 13:47
  • BTW: If this is really all the batch file contains, delete the batch file and create instead a shortcut file with the property __Target__ being `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell..exe -NoProfile -ExecutionPolicy Bypass -File "C:\Full Path to\ScriptFile.ps1"` and define property __Start in__ with the directory path __not__ enclosed in `"` which should be the current directory on execution of PowerShell for interpreting the script file. I suggest also running once on `PATH` restored `powershell /?` and read the output usage help. `-Command` makes no sense on script run. – Mofi Aug 18 '23 at 13:54
  • Can you explain in a simpler way please) – Niner Aug 18 '23 at 16:24
  • How should we explain you what is wrong in your environment variables configuration for the most important environment variable `Path` without seeing the __system__, __user__ and __local__ `PATH` definition. Run the three commands and add their output to the question. Than we can see what is currently configured on your computer and we can tell you what and how to fix the `PATH` configuration. – Mofi Aug 18 '23 at 16:36

0 Answers0