windows.bat 脚本中的 Measure-Command:找不到命令
Measure-Command in windows .bat script: command not found
我正在尝试编写一个脚本来测量程序的执行时间。
如果我直接在 PowerShell 上输入命令 Measure-Command
它就可以了。
如果我在脚本中包含该命令,PowerShell 会告诉我 "command not found"。
有人能帮帮我吗?
.bat
脚本不是由 powershell.exe
而是由 cmd.exe
执行的。由于 Measure-Command
是 PowerShell cmdlet,cmd.exe 无法识别它。
如果愿意,您可以从 .bat
脚本调用 PowerShell:
powershell -command "Measure-Command {Do-Something -Param1 stuff}|Select -Exp TotalSeconds" >> timing.txt
我正在尝试编写一个脚本来测量程序的执行时间。
如果我直接在 PowerShell 上输入命令 Measure-Command
它就可以了。
如果我在脚本中包含该命令,PowerShell 会告诉我 "command not found"。
有人能帮帮我吗?
.bat
脚本不是由 powershell.exe
而是由 cmd.exe
执行的。由于 Measure-Command
是 PowerShell cmdlet,cmd.exe 无法识别它。
如果愿意,您可以从 .bat
脚本调用 PowerShell:
powershell -command "Measure-Command {Do-Something -Param1 stuff}|Select -Exp TotalSeconds" >> timing.txt