3

I've got as far as I can with this one, but struggling at the last hurdle.

I am attempting to get the uptime of my Windows 7 machine, load it into a variable, trim the current time from the left part of the variable and then write it back from a variable into a .txt file.

All works just fine, except I do not know how to write the variable back into a text file.

Here is what I have:

c:
cd/
uptime.exe > uptime.txt
set /p str=<uptime.txt
echo.%str%
set str=%str:~-16%
echo.%str%

Now the last echo line displays exactly what I want, but how do I write that variable back into uptime.txt?

Thanks in advance for any assistance.

omega1
  • 1,031
  • 4
  • 21
  • 41

1 Answers1

2

You can simply redirect standard output to the file of your choice to achieve your goal. For example:

echo %<name of environment variable>% > <path of file>
echo %str% > uptime.txt
user3613932
  • 1,219
  • 15
  • 16