0

While using the Windows machine we face soo much trouble running the command line scripts on CMD(command prompt). Few commands run successfully but some are not. Why is there any difference between terminal and CMD.

3
  • Can you clarify, what exactly do you mean by "terminal?" Note too there is the command processor (command prompt) which can be termed "CMD" and, there are the .cmd (Batch Files) which can be termed "CMD." See EduCBA: CMD vs BAT. Feb 24, 2022 at 0:10
  • The command prompt available in software development IDE like IntelliJ, Eclipse and VS code is called terminal.
    – Rashid
    Feb 25, 2022 at 11:09
  • Thanks @Rashid. To be of any help we'd need specifics. Which "terminal" exactly is not behaving as expected and what, specifically, is the error or undesired behavior. You've tagged your question with both powershell and shell-script one is very specific, the other is general. Scripts developed for one will not likely run within the other. We need greater specificity. Feb 25, 2022 at 15:57

2 Answers 2

0

The question needs details, like what type of script you're attempting to run, and the specific errors you're getting.

Generally speaking, by default Windows Terminal launches a PowerShell interpreter (but can launch others), whereas cmd.exe launches a command interpreter that's much older and has no PowerShell functionality.

If you're attempting to run a PowerShell script, it needs to be in a PowerShell session (start either PowerShell, PowerShell ISE, Windows Terminal with a PowerShell tab, or if you really want to, you can run in a cmd.exe window by invoking powershell.exe -File MyScript.ps1).

If it's a batch file, either interpreter can run it.

If it's a shell script, it's most likely meant to be executed on Linux.

1
0

In my opinion, the major difference between Windows 'cmd/PS' and Linux 'terminal' is the command line or shell language intepreters.

They are both shells but have different script language, features and modules or packages.

Windows CMD/PS Scripts are usually saved as 'file.bat' or 'file.ps1'. Note PS Scripts such as 'file.ps1' would only run using PowerShell interface while a 'file.bat' can run on both CMD and PowerShell interfaces.

Linux Scripts files are usually saved as 'file.sh' and can only be run on terminal interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.