0

This appears foolish question but, I need to add the instruction like text string, but add other lines less that I need.

tasklist /fi "SessionName eq services" | find /I "Tomcat" | find /I ".exe"

I trying with:

@echo off
set "IniCatching=%date:~0,4%%date:~5,2%%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,5%"
set theFile=%~n0_%IniCatching%.txt
set "tasklistecho=echo tasklist /fi ^"SessionName eq services^" ^| find /I ^"Tomcat^" ^| find /I ^".exe^""
echo Before>>%theFile%
call %tasklistecho%>>%theFile%
echo After>>%theFile%

But, this appears that try to show the result (is not treated like string text else command).

Other form:

@echo off
set "IniCatching=%date:~0,4%%date:~5,2%%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,5%"
set theFile=%~n0_%IniCatching%.txt
set "tasklistinst=tasklist /fi ^"SessionName eq services^" ^| find /I ^"Tomcat^" ^| find /I ^".exe^""
echo "echo..">>%theFile%
echo tasklist:>>%theFile%
echo "inst..">>%theFile%
echo %tasklistinst%>>%theFile%


I have in the file (wServ_wFiles_20141122-170025.07.txt):

"echo.."
tasklist:
"inst.."

In my prompt (not in my file) I have:

tasklist /fi "SessionName eq services" | find /I "Tomcat" | find /I ".exe">>wServ_wFiles_20141122-170025.07.txt

Like you see, the value and ">>" filename is treated like only one String....

when I try with

echo "%tasklistinst%">>%theFile%

I have this:

FIND: Parameter format not correct

Help please...

I want to include my command inside of my file...

2 Answers 2

1

Did you try without echo :

%tasklistinst%>>%theFile%
Sign up to request clarification or add additional context in comments.

Comments

0

Why do you store the string in a variable? This is not necessary, and usually the simplest way is the better:

@echo off
set "IniCatching=%date:~0,4%%date:~5,2%%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,5%"
set theFile=%~n0_%IniCatching%.txt
(
echo Before
echo tasklist /fi "SessionName eq services" ^| find /I "Tomcat" ^| find /I ".exe"
echo After
) >> "%theFile%"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.