You can add '^' to continue the line that you assign to the variable. This creates the command as a single line, so you need to use ';' between statements:
@ECHO off SET LONG_COMMAND= ^ if ($true) ^ { ^ Write-Host "Result is True"; ^ Write-Host "Multiple statements must be separated by a semicolon." ^ } ^ else ^ { ^ Write-Host "Result is False" ^ } START Powershell -noexit -command %LONG_COMMAND%
If the only code that needs to be executed is PowerShell, you can use something like:
;@Findstr -bv ;@F "%~f0" | powershell -command - & goto:eof if ($true){ Write-Host "Result is True" -fore green } else{ Write-Host "Result is False" -fore red } Start-Sleep 5
which passes all lines that do not begin with "; @F" to PowerShell.
Edit: I was able to run PowerShell in a separate window and enable cmd with this:
@@ECHO off @@setlocal EnableDelayedExpansion @@set LF=^ @@SET command=
Please note that after setting the variable "LF" there should be 2 spaces, since we assign a string to the variable.
Rynant
source share