How do I run two commands in one line in Windows CMD?

后端 未结 19 1098
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 00:45

I want to run two commands in a Windows CMD console.

In Linux I would do it like this

touch thisfile ; ls -lstrh

How is it done on

19条回答
  •  无人共我
    2020-11-22 00:55

    When you try to use or manipulate variables in one line beware of their content! E.g. a variable like the following

    PATH=C:\Program Files (x86)\somewhere;"C:\Company\Cool Tool";%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;
    

    may lead to a lot of unhand-able trouble if you use it as %PATH%

    1. The closing parentheses terminate your group statement
    2. The double quotes don't allow you to use %PATH% to handle the parentheses problem
    3. And what will a referenced variable like %USERPROFILE% contain?

提交回复
热议问题