Batch Script Tutorial
Batch Script Resources
Selected Reading
- Batch Script - Logging
- Batch Script - Debugging
- Batch Script - Printing
- Batch Script - Network
- Batch Script - Registry
- Batch Script - Devices
- Batch Script - Aliases
- Batch Script - Process
- Batch Script - Functions
- Batch Script - Return Code
- Batch Script - Input / Output
- Batch Script - DATE & TIME
- Batch Script - Operators
- Batch Script - Decision Making
- Batch Script - Arrays
- Batch Script - Strings
- Batch Script - Comments
- Batch Script - Variables
- Batch Script - Syntax
- Batch Script - Files
- Batch Script - Commands
- Batch Script - Environment
- Batch Script - Overview
- Batch Script - Home
Batch Script Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Batch Script - Logging
Batch Script - Logging
Logging in is possible in Batch Script by using the redirection command.
Syntax
test.bat > testlog.txt 2> testerrors.txt
Example
Create a file called test.bat and enter the following command in the file.
net statistics /Server
The above command has an error because the option to the net statistics command is given in the wrong way.
Output
If the command with the above test.bat file is run as
test.bat > testlog.txt 2> testerrors.txt
And you open the file testerrors.txt, you will see the following error.
The option /SERVER is unknown.
The syntax of this command is −
NET STATISTICS [WORKSTATION | SERVER]
More help is available by typing NET HELPMSG 3506.
If you open the file called testlog.txt, it will show you a log of what commands were executed.
C: p>net statistics /ServerAdvertisements