WSL Bash cmd.exe behavior verification

Exploring Behavior When Running cmd.exe from WSL Bash

Introducing verification of behavior when running cmd.exe from WSL Bash in Linux WSL Bash on Windows.

Vulpes
2 min read
Sep 29, 2025

Introducing verification of behavior when running cmd.exe from WSL Bash in Linux WSL Bash on Windows.

  • Only the first cd is executed
``` cmd.exe - <
  • Both are executed
  • ``` cmd.exe - <
  • For some reason it errors
  • ``` cmd.exe - <
    C:\Users\ifgm2>set ATOM_HOME=C:\.atoms\.atom & atom
    net.js:200
        this._handle.open(options.fd);
                     ^
    
    Error: EINVAL: invalid argument, uv_pipe_open
        at new Socket (net.js:200:18)
        at createWritableStdioStream (internal/process/stdio.js:164:16)
        at process.getStdout [as stdout] (internal/process/stdio.js:14:14)
        at console.js:246:38
        at NativeModule.compile (bootstrap_node.js:596:7)
        at Function.NativeModule.require (bootstrap_node.js:541:18)
        at setupGlobalConsole (bootstrap_node.js:310:41)
        at startup (bootstrap_node.js:70:7)
        at bootstrap_node.js:608:3
    • Only the first command is executed
    ``` cmd.exe - <
  • Both are executed
  • ``` cmd.exe /C "cd & cd" ```
    • Nothing is output and nothing is executed
    ``` cmd.exe /C <<'EOT' cd cd EOT ```
    • Nothing is output and nothing is executed
    ``` cmd.exe /C <<'EOT' set ATOM_HOME=C:.atoms.atom02 atom EOT ```
    • Nothing is output and nothing is executed
    ``` cmd.exe /C <<'EOT' set ATOM_HOME=C:.atoms.atom02 & atom EOT ```
    • Both are executed
    ``` cmd.exe /C 'set ATOM_HOME=C:.atoms.atom02 & atom' ``` ## Batch file verification ``` cat > hoge.bat cd cd ```
    • Logs into prompt
    ``` cmd.exe hoge.bat ```
    • Errors (bug)
    ``` cmd.exe /C hoge.bat ``` ``` 'hoge.bat' is not recognized as an internal or external command, operable program or batch file. ``` [Execute Batch file in Windows Subsystem for Linux - Stack Overflow](https://stackoverflow.com/questions/48582952/execute-batch-file-in-windows-subsystem-for-linux) ## Conclusion When you want to execute multiple commands, don't use batch files or here documents, but write them concatenated with &. e.g. cmd.exe /C 'set ATOM_HOME=C:\.atoms\.atom02 & atom'

    batch file - How do I run two commands in one line in Windows CMD? - Stack Overflow

    Share this article

    Vulpes Sep 29, 2025

    ๐Ÿ”— Copy Links