• Turnssoft
  • Software
    • RoboCop RoboCopy >
      • Robocop Robocopy
      • FAQ
      • Forum
      • Your Feedback
      • Update Log
      • Donate
      • Download
    • Simple File Encryptor >
      • Simple File Encryptor
      • FAQ
      • Forum
      • Your Feedback
      • Update Log
      • Donate
      • Download
    • Mini Mouse Macro >
      • Mini Mouse Macro
      • Mini Mouse Macro PRO
      • Mini Mouse Macro EULA
      • FAQ
      • Conditions
      • plugins
      • Tutorials >
        • Tutorial 1 - Record a basic macro
        • Tutorial 2 - Working with Conditions
      • Forum
      • MMM Youtube
      • Update Log
      • BugTrack
      • Donate
      • Download
    • Mini Mouse Macro PRO >
      • Mini Mouse Macro Pro
      • Mini Mouse Macro Pro Business
      • MMM Pro Update
    • MMM Controller
    • Porky Port Scanner >
      • Porky Port Scanner
      • Forum
      • Download
    • IP Change
    • Downloads
  • Shop
  • Forum
    • Turnssoft Forum
  • How To's
    • Visual Basic
    • Windows Batch
    • Raspberry Pi >
      • Shell in a Box
  • Contact
    • Contact
    • Donate
Turnssoft - Software development

Windows Batch

Picture
Below are a few examples and code snippets useful to manipulate the windows command line.  Creating batch jobs for the windows command interpreter is a good skill to have up your sleeve and being able to automate tasks here will save you a lot of time in the long run.

  • Loading Template
  • Batch Beep

loading template

Picture
The Loading Template
The batch loading template is useful if your batch script is set to iterate through a series of tasks before executing the main content of the script.  This allows for a visual representation of the script working those tasks and an indication of the progress. 

The script is simply ASCII block characters that step forward after each event or task that has completed giving the look of a progress bar progressing. 

This step is processed by counter variable addition (inti and intk) and a if condition checking the values resulting in what state the progress bar will be displayed in the batch window.

For the template notice the ping -n 2 127.0.0.1>nul under the number headings to simulate tasks being run.  This command actually pings the localhost with 2 packets however the >nul disposes of the output.  I like using this statement for short breaks in the scripts.  Remove the 'pause' from after the MAIN lable after you have added your running tasks.









loading_template.bat
File Size: 3 kb
File Type: bat
Download File


@echo off
:HEAD
setlocal

:START
color ec
set strStartcurrent=Building -template...
set inti=0
set intk=15
:STARTTITLE
title=   Script name... - Loading...%strStartcurrent%
set /a inti+=1
cls
echo.
echo.
echo            ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo            º                     º
echo            º     .-title....     º
echo            º       LOADING       º
echo            º                     º

if %inti% LSS %intk% (
      if "%inti%"=="1" (echo            º   [.............]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 1)
      if "%inti%"=="2" (echo            º   [Û            ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 2)
      if "%inti%"=="3" (echo            º   [ÛÛ           ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 3)
      if "%inti%"=="4" (echo            º   [ÛÛÛ          ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 4)
      if "%inti%"=="5" (echo            º   [ÛÛÛÛ         ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 5)
      if "%inti%"=="6" (echo            º   [ÛÛÛÛÛ        ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 6)
      if "%inti%"=="7" (echo            º   [ÛÛÛÛÛÛ       ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 7)
      if "%inti%"=="8" (echo            º   [ÛÛÛÛÛÛÛ      ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 8)
      if "%inti%"=="9" (echo            º   [ÛÛÛÛÛÛÛÛ     ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 9)
      if "%inti%"=="10" (echo            º   [ÛÛÛÛÛÛÛÛÛ    ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 10)
      if "%inti%"=="11" (echo            º   [ÛÛÛÛÛÛÛÛÛÛ   ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 11)
      if "%inti%"=="12" (echo            º   [ÛÛÛÛÛÛÛÛÛÛÛ  ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 12)
      if "%inti%"=="13" (echo            º   [ÛÛÛÛÛÛÛÛÛÛÛÛ ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 13)
      if "%inti%"=="14" (echo            º   [ÛÛÛÛÛÛÛÛÛÛÛÛÛ]   º) & (echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ) & (ping -n 1 127.0.0.1>nul) & (GOTO 14)
)

echo            º   [ÛÛÛÛÛÛÛÛÛÛÛÛÛ]   º
echo            ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
GOTO 15

:1
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:2
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:3
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:4
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:5
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:6
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:7
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:8
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:9
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:10
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:11
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:12
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:13
ping -n 1 127.0.0.1>nul
GOTO STARTTITLE
:14
ping -n 2 127.0.0.1>nul
GOTO STARTTITLE
:15
echo.

:MAIN
pause

:END
EXIT

Batch beep

Picture
A beep from your batch file is handy as a notification for users of incorrect input or to grab attention after you have scripted some events.

To output the system bell 'beep' sound from your batch file you need one of three things:
  1. A full length keyboard to type the ASCII character into your batch file that represents the system bell; 
  2. Copy and paste the code below into your batch file; or
  3. Download the batch_beep.bat file below.

To type the ASCII charactor into your batch file hold the left ALT and press the number 7 on your number pad.  You will need a full size keyboard for this.  A laptop keyboard will not work.
You can find a list of other ASCII charactors to give your batch scripts like here.

batch_beep.bat
File Size: 0 kb
File Type: bat
Download File


@echo off
set i=0
color 0A
title=Turnssoft.com - Batch Beep Demo
set /p nulX=Hit any key to begin...
:HEAD
cls
echo.
echo  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» 
echo  º                                                º 
echo  º             www.Turnssoft.com                  º 
echo  º                                                º 
echo  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ 
echo.
echo    - Batch Beep demo..
ping -n 2 127.0.0.1>nul
echo •
set /a i = i + 1
if "%i%"=="4" (EXIT) else (GOTO HEAD)



apps

Robocop Robocopy
Simple File Encryptor
Mini Mouse Macro
Mini Mouse Macro PRO
Porky Port Scanner
Easy IPChange

turnssoft

Downloads
Donate
Contact Us
PGP Public Key
Shop

support

Forum
How to

Turnssoft TS Logo
© Turnssoft 2020