Comprehensive List of Batch Commands with Descriptions - Printable Version +- WildlandsTech (https://wildlandstech.com) +-- Forum: Programming (https://wildlandstech.com/forumdisplay.php?fid=3) +--- Forum: Batch & Shell Scripting (https://wildlandstech.com/forumdisplay.php?fid=42) +--- Thread: Comprehensive List of Batch Commands with Descriptions (/showthread.php?tid=139) |
Comprehensive List of Batch Commands with Descriptions - Sneakyone - 09-03-2024 Comprehensive List of Batch Commands with Descriptions Batch scripting in Windows uses a variety of commands to perform tasks such as file manipulation, system administration, and task automation. Below is a comprehensive list of Batch commands with descriptions. 1. @echo off Description: Turns off the display of commands in the script. Only the output of the commands will be shown. Code: @echo off 2. echo Description: Displays a message or turns the command echoing on or off. Code: echo Hello, World! 3. pause Description: Pauses the script and displays a message prompting the user to press any key to continue. Code: pause 4. cls Description: Clears the Command Prompt window. Code: cls 5. REM Description: Adds a comment in the script. Comments are ignored during execution. Code: REM This is a comment 6. set Description: Sets or displays environment variables. Can also be used to prompt for user input. Code: set myVar=Hello 7. if Description: Performs conditional processing in a Batch script. Code: if %age% GEQ 18 echo You are an adult. 8. for Description: Iterates over a set of files, a range of numbers, or the contents of a directory. Code: for %%i in (*.txt) do echo %%i 9. goto Description: Directs the script to jump to a labeled section within the script. Code: goto start 10. call Description: Calls another Batch script or function within the script. Returns to the calling script when the called script completes. Code: call otherScript.bat 11. exit Description: Exits the Command Prompt or terminates the script. Can also return an exit code. Code: exit 12. start Description: Starts a separate window to run a specified program or command. Code: start notepad.exe 13. dir Description: Displays a list of files and directories in the current directory. Code: dir 14. cd Description: Changes the current directory. Code: cd \path\to\directory 15. mkdir (md) Description: Creates a new directory. Code: mkdir myfolder 16. rmdir (rd) Description: Removes a directory. The `/s` option removes the directory and all its contents. Code: rmdir myfolder 17. del (erase) Description: Deletes one or more files. The `/q` option suppresses confirmation prompts. Code: del file.txt 18. copy Description: Copies one or more files to another location. Code: copy source.txt destination.txt 19. xcopy Description: Copies files and directories, including subdirectories. Useful for backups. Code: xcopy C:\source\* C:\destination\ /s /e 20. move Description: Moves one or more files or directories from one location to another. Code: move file.txt C:\newfolder\ 21. ren (rename) Description: Renames a file or directory. Code: ren oldname.txt newname.txt 22. attrib Description: Changes the attributes of a file or directory. Attributes include read-only, hidden, system, and archive. Code: attrib +r file.txt 23. tasklist Description: Displays a list of currently running processes. Code: tasklist 24. taskkill Description: Ends one or more tasks or processes. Use `/f` to forcefully terminate a process. Code: taskkill /im notepad.exe 25. shutdown Description: Shuts down, restarts, or logs off the computer. Code: shutdown /s /f /t 0 26. netstat Description: Displays network statistics, active connections, and listening ports. Code: netstat 27. ipconfig Description: Displays IP network configuration information. Code: ipconfig 28. ping Description: Sends ICMP echo requests to network hosts to check connectivity. Code: ping 192.168.1.1 29. findstr Description: Searches for a specific text string in files or input. Code: findstr "Hello" file.txt 30. title Description: Sets the title of the Command Prompt window. Code: title My Batch Script 31. color Description: Changes the foreground and background colors of the Command Prompt. Code: color 0A 32. cls Description: Clears the Command Prompt window. Code: cls 33. time Description: Displays or sets the system time. Code: time 34. date Description: Displays or sets the system date. Code: date 35. ver Description: Displays the version of the Windows operating system. Code: ver 36. help Description: Provides help information for commands. Use `help` followed by a command name for detailed information. Code: help Conclusion This list of Batch commands provides a solid foundation for creating and understanding Batch scripts. By mastering these commands, you can automate tasks, manage files, and configure your Windows environment with ease. Experiment with these commands, combine them in scripts, and start automating your workflows. Happy Scripting! |