anyone have any documentation on how if possible to write out a text file using a dos batch file?
for example in the dos batch file i want it to create a text file (doesn't matter where on the drive) that says HELLO
Printable View
anyone have any documentation on how if possible to write out a text file using a dos batch file?
for example in the dos batch file i want it to create a text file (doesn't matter where on the drive) that says HELLO
Place the line below in the batch file and it will write the word hello in a text file.
echo hello >Hello.txt
Try the following (in a batch file):
ECHO HELLO > TESTTEXT.TXT
what about error messages... can i write them out?
lets say i have a line
erase myfile.dll
but the dll is in use so it can't be deleted and DOS tells me so.. can I output the error message from DOS into the text file?
Code:erase myifle.dll > mylog.log
BTW: ">" will create a new file (if it doesn't exist) or, will overwrite the file (if it does exist).
">>" Will append to an existing file.
nice.. thanks for the tips guys..Quote:
Originally posted by techgnome
BTW: ">" will create a new file (if it doesn't exist) or, will overwrite the file (if it does exist).
">>" Will append to an existing file.
i am having trouble registering components via a batch file when my app is launched.. but it is only sometimes.. so i want to track down the exact error..
if it creates the text file.. but it is empty.. does that mean no error occured erasing the file?Quote:
Originally posted by jim mcnamara
Code:erase myifle.dll > mylog.log
this doesn't output the error message.. it just outputs "c:\dir\myfile.dll" to the text fileQuote:
Originally posted by jim mcnamara
Code:erase myifle.dll > mylog.log
Try this. I believe its right, but I have never actually used it :
Redirection using only the > or >> symbols does not output error messages to the text file. To get error messages also, use 2> or 2>>.
Examples:
net use X: \\servername\share$ >>out.txt 2>>out-err.txt
net stop servicename >>out.txt 2>>out-err.txt
this does not workQuote:
Originally posted by JordanChris
Try this. I believe its right, but I have never actually used it :
Redirection using only the > or >> symbols does not output error messages to the text file. To get error messages also, use 2> or 2>>.
Examples:
net use X: \\servername\share$ >>out.txt 2>>out-err.txt
net stop servicename >>out.txt 2>>out-err.txt
This process worked for me maybe i'm doing it differnetly then you are for trapping the error message. attached is my batch file and below are the steps that I used to validate this
1) I went into VB and created blank project with just a form and called it the default name of Project1.exe, then I ran this project on the c drive of my machine
2) I ran this batch file which tries to delete the project1.exe while it is running
errorlog.txt is the file it created and test.bat is the file that I ran.