├── docs
└── github
│ └── graphical_resources
│ └── Logo-without_background-Interactive-Batch-Script-Template.png
├── LICENSE
├── .gitignore
├── README.md
└── InteractiveBatchScriptTemplate.bat
/docs/github/graphical_resources/Logo-without_background-Interactive-Batch-Script-Template.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/franckferman/Interactive-Batch-Script-Template/HEAD/docs/github/graphical_resources/Logo-without_background-Interactive-Batch-Script-Template.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Franck FERMAN
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # ==============================
2 | # 🪟 Windows Batch / CMD
3 | # ==============================
4 |
5 | # Temporary and backup batch files
6 | *.bak
7 | *.tmp
8 | *.old
9 | *.backup
10 |
11 | # Logs and outputs
12 | *.log
13 | *.out
14 | *.err
15 |
16 | # Windows-specific system files (if copied accidentally)
17 | Thumbs.db
18 | Desktop.ini
19 |
20 | # Generated lock or pid files
21 | *.pid
22 | *.lock
23 |
24 | # ==============================
25 | # 🛠️ Compilation & Binaries
26 | # ==============================
27 |
28 | # Binary files (compiled)
29 | bin/
30 | obj/
31 | *.o
32 | *.so
33 | *.a
34 | *.la
35 | *.lo
36 | *.dylib
37 | *.exe
38 | *.dll
39 | *.com
40 |
41 | # Results for `make`
42 | Makefile~
43 | *.d
44 |
45 | # ==============================
46 | # 📝 Text editors
47 | # ==============================
48 |
49 | # Vim
50 | *.swp
51 | *.swo
52 | *.swn
53 | *.viminfo
54 |
55 | # Nano
56 | .nanorc
57 | *.save
58 |
59 | # VSCode
60 | .vscode/
61 | *.code-workspace
62 |
63 | # Sublime Text
64 | *.sublime-project
65 | *.sublime-workspace
66 |
67 | # JetBrains (PyCharm, IntelliJ, WebStorm)
68 | .idea/
69 | *.iml
70 |
71 | # Emacs
72 | *~
73 | *.spacemacs
74 |
75 | # ==============================
76 | # 💾 Operating systems
77 | # ==============================
78 |
79 | # macOS
80 | .DS_Store
81 | .AppleDouble
82 | .LSOverride
83 | .Spotlight-V100/
84 | .Trashes/
85 | ._*
86 | __MACOSX/
87 |
88 | # Windows
89 | Thumbs.db
90 | ehthumbs.db
91 | *.lnk
92 | Desktop.ini
93 | $RECYCLE.BIN/
94 |
95 | # Linux
96 | *.lock
97 | *~
98 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | [![Contributors][contributors-shield]](https://github.com/franckferman/Interactive-Batch-Script-Template/graphs/contributors)
5 | [![Stargazers][stars-shield]](https://github.com/franckferman/Interactive-Batch-Script-Template/stargazers)
6 | [![License][license-shield]](https://github.com/franckferman/Interactive-Batch-Script-Template/blob/stable/LICENSE)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
⚙️ Interactive-Batch-Script-Template
15 |
16 | A ready-to-use template for creating interactive batch scripts.
17 |
18 | A clean, ready-to-use foundation to build dynamic batch tools for Windows system management and automation.
19 |
20 |
21 |
22 |
23 | ## 📜 Table of Contents
24 |
25 |
26 | Click to collapse/expand
27 |
28 | - 📖 About
29 | - 🛠️ Installation
30 | - 🎮 Usage
31 | - 📜 License
32 | - 📞 Contact
33 |
34 |
35 |
36 | ## 📖 About
37 |
38 | **Interactive-Batch-Script-Template** is a **lightweight and flexible base** for building **interactive batch scripts** tailored for **Windows system automation, admin tasks, and maintenance**.
39 |
40 | > ⚙️ **Note**: Originally created for **personal and professional use**, this template is shared publicly to help others save time and **get a clean head start** when scripting in batch.
41 | > It's **simple**, **efficient**, and **modular** — perfect for anyone needing a quick and organized starting point without reinventing the wheel.
42 |
43 | (🔼 Back to top)
44 |
45 | ## 🚀 Installation
46 |
47 | ### Prerequisites
48 |
49 | - **Windows OS** (Tested on **Windows 10 & 11** — might work on older versions, but not officially supported).
50 | - **Command Prompt (cmd.exe)**.
51 |
52 | > ⚠️ **Note**: Pure batch — **no external software or dependencies required**.
53 |
54 | ### Getting the Template
55 |
56 | You can **easily download** and start using this template in seconds.
57 |
58 | **Direct Download (via CMD)**:
59 | Open cmd.exe and use the following command to download the batch script:
60 | ```bash
61 | curl.exe -sO https://raw.githubusercontent.com/franckferman/Interactive-Batch-Script-Template/refs/heads/stable/InteractiveBatchScriptTemplate.bat
62 | ```
63 |
64 | (🔼 Back to top)
65 |
66 | ## 🎮 Usage
67 |
68 | ### Quick Start
69 |
70 | 1. Open Command Prompt (`cmd.exe`) in the folder where you downloaded the script.
71 | 2. Run the script:
72 | ```bash
73 | InteractiveBatchScriptTemplate.bat
74 | ```
75 | 3. Follow the interactive menu and make your selections.
76 |
77 | ### Customization
78 |
79 | You can edit the .bat file to add your own functions, menus, or custom logic. The template includes ready-made examples to help you get started with interactive user prompts, input validation, and dynamic menus.
80 |
81 | (🔼 Back to top)
82 |
83 | ## 📚 License
84 |
85 | This project is licensed under the GNU Affero General Public License, Version 3.0. For more details, please refer to the LICENSE file in the repository: [Read the license on GitHub](https://github.com/franckferman/Interactive-Batch-Script-Template/blob/stable/LICENSE)
86 |
87 | (🔼 Back to top)
88 |
89 | ## 📞 Contact
90 |
91 | [![ProtonMail][protonmail-shield]](mailto:contact@franckferman.fr)
92 | [![LinkedIn][linkedin-shield]](https://www.linkedin.com/in/franckferman)
93 | [![Twitter][twitter-shield]](https://www.twitter.com/franckferman)
94 |
95 | (🔼 Back to top)
96 |
97 |
98 |
99 | [contributors-shield]: https://img.shields.io/github/contributors/franckferman/Interactive-Batch-Script-Template.svg?style=for-the-badge
100 | [contributors-url]: https://github.com/franckferman/Interactive-Batch-Script-Template/graphs/contributors
101 | [stars-shield]: https://img.shields.io/github/stars/franckferman/Interactive-Batch-Script-Template.svg?style=for-the-badge
102 | [stars-url]: https://github.com/franckferman/Interactive-Batch-Script-Template/stargazers
103 | [license-shield]: https://img.shields.io/github/license/franckferman/Interactive-Batch-Script-Template.svg?style=for-the-badge
104 | [license-url]: https://github.com/franckferman/Interactive-Batch-Script-Template/blob/stable/LICENSE
105 | [protonmail-shield]: https://img.shields.io/badge/ProtonMail-8B89CC?style=for-the-badge&logo=protonmail&logoColor=blueviolet
106 | [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=blue
107 | [twitter-shield]: https://img.shields.io/badge/-Twitter-black.svg?style=for-the-badge&logo=twitter&colorB=blue
108 |
109 |
--------------------------------------------------------------------------------
/InteractiveBatchScriptTemplate.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | SetLocal EnableExtensions DisableDelayedExpansion
3 |
4 |
5 | :: Check for administrative privileges
6 | net session >nul 2>&1
7 | if %errorlevel% neq 0 (
8 | color 4
9 | echo Administrator rights are required to run this script properly.
10 | echo.
11 | pause
12 | color 7
13 | exit
14 | )
15 |
16 |
17 | :main
18 | cls
19 | title Interactive Batch Script Template
20 | color 0a
21 | echo.
22 | echo ######## ######## ### ## ## ###### ## ##
23 | echo ## ## ## ## ## ### ## ## ## ## ##
24 | echo ## ## ## ## ## #### ## ## ## ##
25 | echo ###### ######## ## ## ## ## ## ## #####
26 | echo ## ## ## ######### ## #### ## ## ##
27 | echo ## ## ## ## ## ## ### ## ## ## ##
28 | echo ## ## ## ## ## ## ## ###### ## ##
29 | echo.
30 | echo ######## ######## ######## ## ## ### ## ##
31 | echo ## ## ## ## ### ### ## ## ### ##
32 | echo ## ## ## ## #### #### ## ## #### ##
33 | echo ###### ###### ######## ## ### ## ## ## ## ## ##
34 | echo ## ## ## ## ## ## ######### ## ####
35 | echo ## ## ## ## ## ## ## ## ## ###
36 | echo ## ######## ## ## ## ## ## ## ## ##
37 | echo.
38 | echo Interactive Batch Script Template.
39 | echo.
40 | echo 0 - Help: Display information about script options.
41 | echo 1 - Ping Utility
42 | echo 2 - DNS Flush Utility
43 | echo 3 - Show Date and Time
44 | echo 4 - Assign a Network Drive
45 | echo 9 - Exit
46 | echo.
47 |
48 |
49 | :inputChoice
50 | set /p userChoice="Your choice: "
51 | if "%userChoice%"=="9" goto quit
52 | if "%userChoice%"=="0" goto help
53 | if "%userChoice%"=="1" goto pingUtility
54 | if "%userChoice%"=="2" goto flushDNS
55 | if "%userChoice%"=="3" goto showDateTime
56 | if "%userChoice%"=="4" goto assignNetworkDrive
57 | echo.
58 | echo Invalid choice, please try again.
59 | pause
60 | goto main
61 |
62 |
63 | :ShowMenu
64 | cls
65 | echo Interactive Batch script base template.
66 | echo.
67 | echo 0 - Help: Display information about script options.
68 | echo 1 - Ping Utility
69 | echo 2 - DNS Flush Utility
70 | echo 3 - Show Date and Time
71 | echo 4 - Assign a Network Drive
72 | echo 9 - Exit
73 | goto :eof
74 |
75 |
76 | :help
77 | cls
78 | echo This script serves as a base template for creating interactive batch scripts.
79 | echo It demonstrates basic functionalities such as:
80 | echo.
81 | echo 0 - Help: Display this help information.
82 | echo 1 - Ping Utility: An example function that pings a specified IP address or hostname.
83 | echo 2 - DNS Flush Utility: An example function that flushes the DNS resolver cache.
84 | echo 3 - Show Date and Time: An example function that displays the current system date and time.
85 | echo 4 - Assign a Network Drive: An example function that maps a network drive to a drive letter.
86 | echo 9 - Exit: Exits the script.
87 | echo.
88 | pause
89 | goto main
90 |
91 |
92 | :pingUtility
93 | cls
94 | color 7
95 | echo ---------------------------------------
96 | echo Ping Utility
97 | echo ---------------------------------------
98 | :askForIP
99 | set "ipAddr="
100 | set /p ipAddr="Please enter the IP address, machine name, or website to ping (e.g., 192.168.0.1 or github.com): "
101 | if not defined ipAddr (
102 | echo You must enter a value.
103 | echo.
104 | goto askForIP
105 | )
106 | ping -a -n 4 -w 2000 -4 %ipAddr%
107 | echo.
108 | pause
109 | goto main
110 |
111 |
112 | :flushDNS
113 | cls
114 | color 7
115 | echo ---------------------------------------
116 | echo DNS Flush Utility
117 | echo ---------------------------------------
118 | ipconfig /flushdns
119 | echo.
120 | pause
121 | goto main
122 |
123 |
124 | :showDateTime
125 | cls
126 | color 7
127 | echo ---------------------------------------
128 | echo Current Date and Time Display
129 | echo ---------------------------------------
130 | echo The current system date and time is: %date% at %time%.
131 | echo.
132 | pause
133 | goto main
134 |
135 |
136 | :assignNetworkDrive
137 | cls
138 | color 7
139 | echo ---------------------------------------
140 | echo Network Drive Assignment Utility
141 | echo ---------------------------------------
142 | :NetworkDrive
143 | set "NetworkDrive="
144 | set /p NetworkDrive="Please enter the letter for the network drive: "
145 | if not defined NetworkDrive (
146 | echo You must enter a drive letter.
147 | echo.
148 | goto NetworkDrive
149 | )
150 |
151 | :NetworkPath
152 | echo.
153 | set "networkPath="
154 | set /p networkPath="Please enter the network path (e.g., \\192.168.1.10\franckferman): "
155 | if not defined networkPath (
156 | echo You must enter a network path.
157 | echo.
158 | goto NetworkPath
159 | )
160 |
161 | :Username
162 | echo.
163 | set "username="
164 | set /p username="Enter the username (domain\username or .\username for local): "
165 | if not defined username (
166 | echo You must enter a username.
167 | echo.
168 | goto Username
169 | )
170 |
171 | :Password
172 | echo.
173 | set "password="
174 | set /p password="Enter the password (input will be visible): "
175 | if not defined password (
176 | echo You must enter a password or a space if none.
177 | echo.
178 | goto Password
179 | )
180 |
181 | echo.
182 | echo Attempting to assign the network drive...
183 | net use %NetworkDrive%: /delete >nul 2>&1
184 | net use %NetworkDrive%: "%networkPath%" /user:"%username%" "%password%" /persistent:yes
185 | if %errorlevel% == 0 (
186 | echo Network drive %NetworkDrive%: has been successfully assigned.
187 | ) else (
188 | echo Failed to assign the network drive.
189 | )
190 | echo.
191 | pause
192 | goto main
193 |
194 |
195 | :quit
196 | cls
197 | color 7
198 | exit /b
199 |
--------------------------------------------------------------------------------