Pelican Media
Pelican Media

Reputation: 13

Batch file not echoing to file

bat file that should echo lines to another .bat file (). I'm sure it was working fine, but for some reason is not now...

echo @echo off > %USERPROFILE%\Documents\Richmond\check_node.bat
echo pushd >> %USERPROFILE%\Documents\Richmond\check_node.bat
echo tasklist /nh /fi "imagename eq node.exe" | find /i "node.exe" > nul ||(start %USERPROFILE%\Documents\Richmond\server.bat) >> %USERPROFILE%\Documents\Richmond\check_node.bat

Outputs only...

@echo off 
pushd 

It's completely ignoring the last line.

Any help would be appreciated.

Upvotes: 1

Views: 69

Answers (1)

Hackoo
Hackoo

Reputation: 18827

You need to escape characters when you want to create a batch file like that :

Give a try for this modification :

@echo off
Set "check_node=%USERPROFILE%\Documents\Richmond\check_node.bat"
Set "server=%USERPROFILE%\Documents\Richmond\server.bat"
(
    echo @echo off 
    echo pushd 
    echo tasklist /nh /fi "imagename eq node.exe" ^| find /i "node.exe" ^>nul ^|^|(start "" "%server%"^)
)> "%check_node%

Upvotes: 3

Related Questions