DEV Community

charandeepsinghb
charandeepsinghb

Posted on

Why use Batch in Windows

In this age of software development, when we try to develop a personal project or try to work on an existing project, we tend to fall towards latest technologies. Like when I would look up the internet to learn new technologies there are some which would pop out of somewhere like Docker, Containerization, WSL (windows subsystem for linux) which are good.....

When we think of Dockerizing any software it is possible to do that, but do we have to.....

I find Docker and WSL as a bit of a cheating with the system, cause we are trying to use our operating system with a layer in between to run our software in a somewhat virtualized environment (Docker is faster and better than virtual machines and a totally different concept from Virtual machines). So with that in mind we are not getting a full potential of our system to develop the requirement. Then why do we want to optimize everything as much as possible when we ignore these things. 😊 I am a beginner developer, but I want to make software which runs faster and easy to deploy (docker makes those promises up-to some extent). In small applications I don't recommend beginners to start learning Docker or not to use if for everything.

That part does not holds up with the title "Batch" right??? :) XD

On the right track, Batch!!!

Why use batch when you can learn bash right 🤷‍♀️ and use it everywhere wherever Linux is

Batch scripting allows us to write short and easy to write scripts which automate our daily tasks in software development. For example, if I were to start my system how do I start doing my development (Opening software which are needed to getting started from where we left off last time)

How you would open the required software and start working Manually right?? I don't recommend doing that when you can do automate as much as possible if it is easy and takes little effort
So if I have to open project in VSCode, Eclipse for the backend, Sourcetree and Slack at the same time to start working (Obviously chrome (any browser of you choice) is needed to write and search for every single line of code (how to do ....)😂🤣) Choice is I can open all these manually click, click, click, mouse movement ..... OR I have a script file at desktop to open everything at once which is

start_env.bat

@echo off

choice /M "Start everything (Chrome, eclipse, sourcetree, slack)?"
if %ERRORLEVEL% neq 1 (
    exit
)

start "" "Chrome.lnk"
start "" "Eclipse.lnk"
start "" Sourcetree.lnk
start "" Slack.lnk
Enter fullscreen mode Exit fullscreen mode

How difficult was that!! 🔥

Now when you click on that file it prompts you if you want to open everything or not Image description
A command prompt showing output of the executed commands

This was simple and easy, how about if we want to start working on a new project without touching any of our files in the system using any environment. Well I have scripts for that as well >

Starting VSCode for a new project which is isolated from outside VSCode environments.

start_project.bat

rem This is a comment in bat file
PATH=%PATH%;{...Your project dependencies go here...}
rem You can omit %PATH% if you want to isolate and 
rem copy parts of path manually which you want to use.

start cmd
rem this could also be like
start code {project_folder}
Enter fullscreen mode Exit fullscreen mode

For this I download zip version of VSCode and place it outside the project folder. For dependencies I do the same zip portable versions (not running in the background, without admin rights as well :)). In this example I've added changed the path and starting the cmd. You can start code (VSCode) at a specific location......................⌛🔮⚡

Latest comments (0)