0

What's the equivalent "&&" (Linux) in Windows Powershell to combine two commands?

Linux

cd /var/www/html/server && env/Script/activate

Windows ???

dazzafact
  • 2,570
  • 3
  • 30
  • 49
  • 2
    In short: Only [_PowerShell (Core) v7+_](https://github.com/PowerShell/PowerShell/blob/master/README.md) supports `&&` and `||`, the pipeline-chaining operators, not the legacy _Windows PowerShell_ edition (versions up to 5.1). In earlier versions, notably in _Windows PowerShell_, you can emulate `a && b` with `a; if ($?) { b }` and `a || b` with `a; if (-not $?) { b }` or, for _external programs_, more robustly, `if ($LASTEXITCODE -eq 0)`, `if ($LASTEXITCODE -ne 0)` - see [this answer](https://stackoverflow.com/a/41816341/45375) for details. – mklement0 Oct 05 '22 at 14:19

0 Answers0