Depending on how much editing you need to do, you can use echo
with output redirection (>
to overwrite a file with your output, >>
to append to a file) to edit a file. For example,
echo This line will replace the contents of this file > file1.txt
echo This line will be appended to the file's end >> file2.txt
If you need to do more fine-grained editing than that and you're on a modern Windows version, you can use powershell
, which gives you a much more powerful scripting engine (although you will still need to script out the editing). If you were actually on DOS (you aren't!), or are on a 32-bit Windows version, you could use edlin
. You do not want to use edlin
.
Of course, since what you're actually trying to do is "edit a file via meterpreter", which has nothing to do with cmd.exe
much less MS-DOS, you should just use meterpreter's edit
command, as the other answers say.