1.

Solve : Looking for >file.txt alternatives?

Answer»

Is there any other way to extract the output of a command in batch file to txt  without USING >file.txt

ThanksYou can use FOR with the /F switch. See the FOR documentation - type FOR /? at the prompt or read here:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true

Thanks for your reply...
I don's see how to use that command to do this. I want to run commands like "HOSTNAME", "wmic bios get serialnumber" and PUT the result in a text file. Can I do that with FOR command? Quote from: FahadOnline on December 28, 2010, 03:35:17 AM

Thanks for your reply...
I don's see how to use that command to do this. I want to run commands like "hostname", "wmic bios get serialnumber" and put the result in a text file. Can I do that with FOR command?

Study carefully the command and all will be CLEAR. I only told you about it 17 minutes ago. Read, learn, consider and practise.

Please show your command in a script and I will try to help.

Please show your command in a script and I will try to help.

Quote from: FahadOnline on December 28, 2010, 03:07:53 AM
Is there any other way to extract the output of a command in batch file to txt  without using >file.txt

Thanks
no, in batch, to write to a file, you have to use the output redirection operators,  >> (append mode) or >.  Even if you use the for loop to get the output of the command, if you want to save the output to a file, you will still need the redirection operators.

Most programming languages other than batch,  will have file i/o facilities for you to open a file handle, write to it, and closing the file handle after writing.


Discussion

No Comment Found