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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -