且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何运行DOS批处理文件中的PowerShell脚本

更新时间:2023-10-27 16:40:40

这其中只有通过正确的行PowerShell的:

This one only passes the right lines to PowerShell:

dosps2.cmd

@findstr/v "^@f.*&" "%~f0"|powershell -&goto:eof
Write-Output "Hello World" 
Write-Output "Hello some@com & again" 

前pression 排除开始 @行˚F键,包括&放大器; 并通过其他一切PowerShell的

The regular expression excludes the lines starting with @f and including an & and passes everything else to PowerShell.

C:\tmp>dosps2
Hello World
Hello some@com & again