
- Batch Script Tutorial
- Batch Script - Home
- Batch Script - Overview
- Batch Script - Environment
- Batch Script - Commands
- Batch Script - Files
- Batch Script - Syntax
- Batch Script - Variables
- Batch Script - Comments
- Batch Script - Strings
- Batch Script - Arrays
- Batch Script - Decision Making
- Batch Script - Operators
- Batch Script - DATE & TIME
- Batch Script - Input / Output
- Batch Script - Return Code
- Batch Script - Functions
- Batch Script - Process
- Batch Script - Aliases
- Batch Script - Devices
- Batch Script - Registry
- Batch Script - Network
- Batch Script - Printing
- Batch Script - Debugging
- Batch Script - Logging
- Batch Script Resources
- Batch Script - Quick Guide
- Batch Script - Useful Resources
- Batch Script - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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:\tp>net statistics /Server
Advertisements