execute complex batch command with cmd /C -
i'm trying run
@echo off & /l %%a in (0) tasklist /fi "imagename eq prog.exe" 2>nul | find "prog.exe" >nul || (echo "update" & exit)
as 1 liner with
cmd.exe /c <----here -->
but cmd crashes immediately. when put exact same command in batch file, works. how need format command make work?
background: i'm trying self update (aka "replace while running") c# executable, without creating external batch script aid of "cmd /c".
as code running not inside batch file, percent signs need not escaped, so, not %%a
%a
the full command needs quoted
cmd /c "@echo off & /l %a in (0) tasklist /fi "imagename eq prog.exe" 2>nul | find "prog.exe" >nul || (echo "update" & exit)"
Comments
Post a Comment