我正在尝试为程序的测量执行时间编写脚本。
如果我直接在PowerShell上输入命令Measure-Command
,它就可以工作。
如果我在脚本中包含该命令,那么PowerShell会告诉我"命令未找到"。
有人可以帮我吗?
答案 0 :(得分:3)
.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