?
Solved

saving string value to a file

Posted on 2014-09-04
2
Medium Priority
?
156 Views
Last Modified: 2014-09-04
I want to save string variable from .cmd to external file. Just to append it not overwrite it. Something like this

current date/time     string value

Is it possible?
0
Comment
Question by:axcx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 1000 total points
ID: 40303316
Just use the "double" redirection, which will append instead of overwrite: ">>". You can add it before or after the echo ..." command, but I prefer it in front so there are no trailing spaces or the need for brackets:
>>"C:\Temp\echo_date.txt" echo current date/time: %Date% %Time%

Open in new window

or (with a trailing space at the end of the line):
echo current date/time: %Date% %Time% >>"C:\Temp\echo_date.txt"

Open in new window

or (no trailing space, but with brackets)
(echo current date/time: %Date% %Time%)>>"C:\Temp\echo_date.txt"

Open in new window

0
 
LVL 9

Assisted Solution

by:dlb6597
dlb6597 earned 1000 total points
ID: 40303321
echo %time% %string% >>output.txt

where %string% is your variable, output.txt is the file you wish to append to.
0

Featured Post

Need protection from advanced malware attacks?

Look no further than WatchGuard's Total Security Suite, providing defense in depth against today's most headlining attacks like Petya 2.0 and WannaCry. Keep your organization out of the news with protection from known and unknown threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question