0

Sorry about the second thread, I forgot to include this on my first one.
Anyways, is it possible for someone to use the "echo %text here% >> %location of file here%" command to save some text to a file in a different folder? I did it, but got a message saying "access denied". I say someone do it with this code:

echo %finalmsg% >> \\BAS-307-15\mikchat\public.txt

But when I do it, for example:

echo %text% >> C:\Documents and Settings\Owner\Desktop\log.txt

It doesn't work! Anyone know whats going on?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by mittelgeek
0

Well the problem with using echo %text% >> [i]C:\Documents and Settings\Owner\Desktop\log.txt[/i] is that the C:\Documents and Settings\Owner\Desktop\log.txt needs to be in quotes.

I would recommend that you use variables because you can define them at the top of the your code and change their value all throughout the code by simply changing them in one place, e.g.,:

set TEXT="Some Text"
set MYLOG="C:\Documents and Settings\%USERNAME%\Desktop\log.txt"

:: Or your can use this method as well
::
:: set MYLOG="%USERPROFILE%\Desktop\log.txt"
::
:: That is the way that I setup a poorman's alias/macro
:: list for my CMD Sessions. That way each user on the
:: computer will have their own set of aliases/macros.

echo "%text%" >> "%mylog%"

type "%mylog%"

Using that method, all you have to do is make the change in the variable at the top and it is modified all throughout the program.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.