Do you often find yourself performing repetitive tasks on your Windows computer? Want to streamline your workflow and add a touch of interactivity to your computing experience?

Look no further! In this guide, we'll walk you through the creation of an interactive batch script that empowers you to execute common actions with just a few keystrokes.

Step 1: Create a New Batch Script

Start by creating a new batch script on your desktop or in a folder of your choice. Here's how:

  1. Right-click on an empty area of your desktop or folder.
  2. Select "New" and then "Text Document."
  3. Rename the text document to something meaningful, like "InteractiveScript.bat."

Step 2: Edit the Batch Script

Once you've created the batch script, it's time to add some functionality. Follow these steps:

  1. Right-click on the .bat file you created.
  2. Choose "Edit" or "Open with" and select a text editor like Notepad.
  3. Copy and paste the following script into the opened .bat file:
@echo off
title Interactive Batch Script

echo ========================
echo     Batch Script Menu
echo ========================
echo 1. Ping Remote IP
echo 2. Ping Internal IP
echo 3. Show External IP
echo 4. Flush DNS
echo 5. Exit

set /p choice=Enter your choice: 

if "%choice%"=="1" goto ping_remote_ip
if "%choice%"=="2" goto ping_internal_ip
if "%choice%"=="3" goto show_external_ip
if "%choice%"=="4" goto flush_dns
if "%choice%"=="5" goto :eof

echo Invalid choice. Please try again.
goto menu

set /p remote_ip=Enter the remote IP address to ping: 
ping %remote_ip%
goto menu

set /p internal_ip=Enter the internal IP address to ping: 
ping %internal_ip%
goto menu

echo Getting external IP address...
powershell -command "(Invoke-WebRequest"
goto menu

ipconfig /flushdns
echo DNS cache has been flushed.
goto menu

Step 3: Save and Run the Script

After pasting the script, save the .bat file and close the text editor. Then, simply double-click on the file to run it.

Step 4: Enjoy the Enhanced Capabilities

Once the script is running, you'll be greeted with a menu offering various options, from pinging remote and internal IP addresses to flushing DNS cache. Simply follow the on-screen instructions to perform the desired action.

Important Note:

For the best experience and to access all features of the script, make sure to run the batch script as an administrator. If you encounter a message asking for administrator privileges, confirm the prompt to proceed.

And that's it! With this interactive batch script, you can streamline your workflow and perform common tasks with ease, making your Windows computing experience more efficient and enjoyable.

Blog Logo

Vincentde Koning

The world is a playground!




Projects, Adventures and Experiments

Back to Overview