0
这似乎是个愚蠢的问题,但是我需要添加像文本字符串这样的指令,但是添加了其他所需的更少的行。将命令追加到CMD脚本中的文件
tasklist /fi "SessionName eq services" | find /I "Tomcat" | find /I ".exe"
我想:
@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%
但是,这似乎试图显示结果(是不是像字符串文本其他命令处理)。
其他形式:
@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....
当我尝试用
echo "%tasklistinst%">>%theFile%
我有这样的:
FIND: Parameter format not correct
请帮助...
我想包括我命令在我的文件里面...