相关疑难解决方法(0)

如何告诉PowerShell在开始下一个命令之前等待每个命令结束?

我有一个PowerShell 1.0脚本来打开一堆应用程序.第一个是虚拟机,其他是开发应用程序.我希望虚拟机在其他应用程序打开之前完成启动.

在bash我可以说 "cmd1 && cmd2"

这就是我所拥有的......

C:\Applications\VirtualBox\vboxmanage startvm superdooper
    &"C:\Applications\NetBeans 6.5\bin\netbeans.exe"
Run Code Online (Sandbox Code Playgroud)

powershell execution wait

198
推荐指数
6
解决办法
39万
查看次数

如何在一行中执行多个命令

我知道Unix有以下命令可以在一行中执行多个命令,我该如何在DOS中执行此操作?

command1 ; command2 ; command3 ...
Run Code Online (Sandbox Code Playgroud)

windows cmd

88
推荐指数
1
解决办法
11万
查看次数

powershell中的条件执行(&&和||)

已经有问题解决我的问题(我可以让&&在Powershell中工作吗?),但有一点不同.我需要两个命令的OUTPUT.看,如果我只是运行:

(command1 -arg1 -arg2) -and (command2 -arg1)
Run Code Online (Sandbox Code Playgroud)

我不会看到任何输出,而是stderr消息.正如所料,只需输入:

command1 -arg1 -arg2 -and command2 -arg1 
Run Code Online (Sandbox Code Playgroud)

给出语法错误.

syntax powershell command-execution

31
推荐指数
2
解决办法
2万
查看次数

什么是Bash的&&和||的PowerShell等价物 运营商?

在Bash中,我可以轻松地做类似的事情

command1 && command2 || command3
Run Code Online (Sandbox Code Playgroud)

这意味着运行command1,如果command1成功运行command2,并且command1无法运行command3.

什么是PowerShell中的等价物?

bash powershell language-comparisons

30
推荐指数
2
解决办法
2万
查看次数

标记“&&”在此版本中不是有效的语句分隔符

在我的 React 项目上安装Webpack的过程中,遇到以下问题阻碍了我的进度:

配置 Webpack 的最后一步

npm run build && node ./dist/main.js
Run Code Online (Sandbox Code Playgroud)

Windows Power Shell / Visual Studio Code 上的错误

PS C:\Users\pythonbuddha\Desktop\to_experiment\to-do-list> npm run build && node ./dist/main.js
At line:1 char:15
+ npm run build && node ./dist/main.js
+               ~~
The token '&&' is not a valid statement separator in this version.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidEndOfLine

Run Code Online (Sandbox Code Playgroud)

承诺配置 webpack 的教程

https://developerhandbook.com/webpack/webpack-4-from-absolute-scratch/

https://developerhandbook.com/webpack/how-to-configure-scss-modules-for-webpack/
Run Code Online (Sandbox Code Playgroud)

javascript powershell reactjs webpack

19
推荐指数
4
解决办法
2万
查看次数

在Windows PowerShell中有条件地执行进程(例如Bash中的&&和||运算符)

我想知道是否有人知道有条件地执行程序的方法取决于前一个程序的退出成功/失败.如果program1在没有测试LASTEXITCODE变量的情况下成功退出,有没有办法在program1之后立即执行program2?我尝试使用-band和-and运算符无济于事,尽管我觉得它们无论如何都不会工作,最好的替代品是分号和if语句的组合.我的意思是,当在Linux上从源代码自动构建一个包时,&&运算符不能被打败:

# Configure a package, compile it and install it
./configure && make && sudo make install
Run Code Online (Sandbox Code Playgroud)

假设我实际上可以在PowerShell中使用相同的构建系统,PowerShell将要求我执行以下操作:

# Configure a package, compile it and install it
.\configure ; if ($LASTEXITCODE -eq 0) { make ; if ($LASTEXITCODE -eq 0) { sudo make install } }
Run Code Online (Sandbox Code Playgroud)

当然,我可以使用多行,将其保存在文件中并执行脚本,但其目的是简洁(保存击键).也许它只是PowerShell和Bash之间的区别(甚至是支持&&运算符的内置Windows命令提示符)我需要调整,但如果有更清洁的方法,我很想知道.

powershell operators exit-code

7
推荐指数
1
解决办法
2125
查看次数

&& Powershell中的等价物

可能的重复:
什么是Bash的&&和||的PowerShell等价物 运营商?
我可以让&&在Powershell中工作吗?

在bash中我./task1.sh && ./task2.sh用来运行task1,然后只要task1没有返回错误代码就运行task2.当我.\task1.bat && .\task2.bat在Powershell中尝试时,我收到错误"令牌&&在此版本中不是有效的分隔符".

Windows Powershell中有&&的等价物吗?

powershell scripting command-line

7
推荐指数
2
解决办法
1万
查看次数

如何在 Powershell 中使用逻辑与 (&&)?

在终端中,我曾经使用“&&”运算符同时运行两个命令。例如,如果我想编译并运行 C 源代码,我只需要编写: gcc code.c && ./a.out。但不幸的是它在 Powershell 中不起作用。我怎样才能做到这一点?很抱歉我找不到任何更简单的方法来做到这一点。因此,我不得不将其发布在这里!蒂亚!

windows terminal powershell

4
推荐指数
1
解决办法
6928
查看次数