How to add string to the end of the file in batch scripting

Hello experts,

I need to add string to the file from  batch script. The string is: cmd /c > filename

echo cmd /c > filename >> c:\temp\abcd.txt

But it is failed on symbol >

Please help
IKeystoneAsked:
Who is Participating?
 
SCDMETAConnect With a Mentor Commented:
Escape the > with a carrat ^

echo cmd /c ^> test >> test.txt
0
 
Ralf KlattConcerned World CitizenCommented:
Hi,

You might try:

echo cmd /c filename>>c:\temp\abcd.txt


Best regards,
Raisor
0
 
shinobunCommented:
echo "cmd /c > filename" >> c:\temp\abcd.txt
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
chhokra_expertCommented:
like shinobun said
 echo "cmd /c > filename" >> c:\temp\abcd.txt
will add the test "cmd /c > filename" to the end of the file.

but more importantly, what's that you are trying to do? the output of comand "cmd /c" will be redirected directed to filename but isn't "cmd /c" used to execute a command? i don't see that as part of your string. as it stands, it will probably just add a blank line to your file (whenever that command gets run). is this what you wanted to do?
0
 
IKeystoneAuthor Commented:
Thanks Raisor.

With symbol ^ everything work fine

0
 
IKeystoneAuthor Commented:
Sorry, Thanks SCDMETA !!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.