I have a script that install several programs.
I would like to write a series of batch scripts to log these installs.
I was hoping to find a command that would allow me to select this text file and write a line to the file each time it runs.
- flash installs
- batch file runs and logs text "flash installed" to
c:\log\logfile.txt - java installs
- batch file runs and writes text "java installed" to
c:\log\logfile.txt - and so on
so that in log file when finished it has
flash installed
java installed
chrome installed
so onso forth
However, I'm finding a lot of scripts for writing to specific lines or editing specific strings of text. I'm not seeing any scripting for just write to the next blank line. Perhaps I'm going about this the wrong way.
2 Answers
To append a line to a text file using a windows command line batch script you can use output redirection using the greater-than sign twice >>. For example
echo "java installed" >> c:\log\logfile.txtRelated:
- Append stdout to file from terminal? (OSX but also applies)
- Using command redirection operators (XP but mostly still applicable)
- Redirecting Error Messages from Command Prompt: STDERR/STDOUT
hey Im actually looking for an answer for something else at the moment and stumbled upon this so i just thought Id post a script I made at my last job
@echo off echo Flash Check
set KEY_NAMEFP=HklM\Software\macromedia\Flashplayer
set VALUE_NAMEFP=CurrentVersion
for /F "usebackq tokens=3" %%A IN (reg query "%KEY_NAMEFP%" /v "%VALUE_NAMEFP%" 2^>nul ^| find "%VALUE_NAMEFP%") do (
set A=%%A )
echo Flash %A%
echo Flash %A%>>%computername%.log
echo IE Check
set KEY_NAMEIE=HklM\Software\microsoft\internet explorer
set VALUE_NAMEIE=svcVersion
for /F "usebackq tokens=3" %%B IN (reg query "%KEY_NAMEIE%" /v "%VALUE_NAMEIE%" 2^>nul ^| find "%VALUE_NAMEIE%") do (
set B=%%B )
echo IE Version %B%
echo IE Version %B%>>%computername%.log
echo Java Check
set KEY_NAMEJ=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment
set VALUE_NAMEJ=CurrentVersion
for /F "usebackq tokens=3" %%C IN (reg query "%KEY_NAMEJ%" /v "%VALUE_NAMEJ%" 2^>nul ^| find "%VALUE_NAMEJ%") do (
set C=%%C )
echo Java Version %C%
echo Java Version %C% >>%computername%.log
pause