[chatGpt] Some bats can only be executed correctly after being opened and saved in win7. What is the reason?

  • Some bats can only be executed correctly after being opened and saved in win7. What is the reason?

  • This may be because Windows 7 uses PowerShell as the script interpreter by default, rather than CMD used in previous versions. Therefore, if CMD-specific syntax or commands are used in the script, it may cause errors when run in PowerShell. After saving and running, the system will pass the script to the CMD interpreter for execution, so it can be executed correctly. In order to avoid this problem, you can add a statement specifying to use CMD as the interpreter at the beginning of the script, such as "@echo off", or explicitly specify to use the CMD interpreter to run the script when running the script.

おすすめ

転載: blog.csdn.net/dualvencsdn/article/details/131402319