Jump to content

[Guide]Ultimate Guide to Batch Scripting


Necro

Recommended Posts

Welcome to the ultimate guide of batch scripting..

Take a look here.. :D


Index

  • Introduction
     
  • What is Batch?
     
  • A History Lesson
     
  • Requirements
     
  • "Hello World"
     
  • FAQ

 

 

Introduction

 

Ever wanted to know everything about batch? I don't mean the basics, I mean EVERYTHING. Well, you have come to the right place! This thread will leave you stuffed with information. By the end of this, your brain will be overflowing with knowledge. :D

 

What is Batch?

 

Well, Batch is a scripting language. Using Batch, you write a batch file, a compiled text file containing commands that will run in order. The name "Batch" was given to this language because a batch file contains a bundle or batch of commands. Batch files were made to finish tasks in a shorter period of time. Batch files also keep your operating system working. In every windows operating system, there is a least one batch file that is crucial to the operation of Windows.

 

A History Lesson

 

As the Windows OS evolved, so did the use of batch files. Long ago, in the early OS versions, batch files were extremely crucial. Early versions of Windows had batch files that actually made the OS start up properly. Over time, batch files became less useful. Windows could sustain most of its frame without the help of batch files. But in a couple of years, batch files became a source of entertainment. How? Well, some people saw the advantages to batch and its endless possibilities. Soon after that, a new era was born. People started making batch games, applications, and even found ways to create simple antiviruses with them. Batch files are still a popular success today. Without those brilliant minds, I wouldn't be writing this guide.

 

Requirements

 

So, most of you may know that all languages have requirements. Usually some special program. For example, C++ requires an IDE and a Compiler to work. So for Batch, is it the same? No. Not at all. All you need is:

Notepad

 

That's it! The only program you need is Notepad. If you don't know yet, notepad is already on your PC. Can't find it ??? Just go to Start Menu > All Programs > Accessories > Notepad. Now... are you ready to write a batch file? :)


"Hello World"

 

Ok, are you ready to write your first batch file? :P Let's get going! First off, open up Notepad.

 

The first line of code we are going to learn is @echo off. Now what does this line do? Well, it stops your batch file from showing file paths. It makes your program look professional. Just make sure you have this in the first line of notepad.

 

So, your notepad should have this in it:

@echo off

 

Now, have you ever wanted to make your program say something? Well if you do, you have to use the echo command. If I wanted my program to say "Hello World!”… I would type this on the second line of notepad:

echo Hello World!

 

So, now your notepad should have this in it:

@echo off
echo Hello World!

 

Let's just say this is our program. Nothing else. If we saved it (you will learn how to later) and ran it, it would pop up then close in less than a second. Why?!  Well, you forgot to tell the program to Pause! What, did you honestly expect it to pause by itself?  So, how do you make it pause? Well, you just put the command pause on the next line. So your notepad should look like this now:

@echo off
echo Hello World!
pause

 

So what actually happens when the pause command is processed during the run? Well, your batch file will pause and a message will appear. Your batch file will say "Press any key to Continue." Then when you press a key, it will move on to the next line of code. If there is no code left, the batch file will close. This may be a bit confusing, but let's run it and you will understand this.

 

So how do I run my program? Well, first you have to save it. Wait. I know what you’re thinking. You just going to go save it as a text document and then just open it. Yes, that is perfectly... WRONG! You don't save it as a text file. You must save it as a batch file! To do this, follow these three simple steps.

 

Step 1: Go to File > Save as

 

Step 2: Name your file but at the end of the name, insert ".bat" or your batch file will not work at all. For example, I can name it "My Program.bat" and that would work.

 

Step 3: For the "Save as Type" select "All Files" not "Text Files." (This is VERY important. If you don't do this, it will be saved as a text document.)

 

There, you have just saved your batch file! Now it's time to run it. Go open the file you just saved. If it does not open, right click the file and select "Run as Administrator." Once it is open, it should look like this:

JPWyN.png

 

First of all, Well Done! You have just made your first batch file! Now, do you see what the Pause command did? It made the batch file say "Press any key to continue..." Then you pressed a key, and it moved on to the next line of code, which is nothing, so it closed.


FAQ

 

How do I Edit my Batch File Again?

 

Just right click your batch file and click "Edit." It will then open up in notepad. Make your changes and then go to File > Save. Then close notepad and run your batch file again. All your changes should come into action.

 

My Batch File Won’t Run! HELP?!

 

Make sure you are on an administrator account. If it is still not running, right click your batch file and click "Run as Administrator." The batch file should run. If it does run but it just closes automatically, then there is an error in the source code you wrote. Go back and check that again.

 

Credits:Me

Link to comment
Share on other sites

Guest Elfocrash

Really Amazing guide,+1 for your job ITS JUST AMAZING

karma fixed.makin a report for your karma abuses.

Link to comment
Share on other sites

Guest Elfocrash

I found it really cool & he made a lot of job to make this guide.

We have +1 to reward people for their job.

yeah ofc.but if it is THEIR job and if it is something unique or saves money for us like raule and psomas' shares or irat shares.not a thing you can just google and get 1million results

Link to comment
Share on other sites

1: Theres no way you could have written this yourself with your English level

2: Ultimate guide? -____________- going over 'echo' isn't really that advanced or helpful in any way

3: Maybe you should know what you're doing first before 'teaching' it to other people

Link to comment
Share on other sites

It is a very good guide but I have to agree with Elfocrash. It does not deserve karma for the reason, that a tutorial like that can be found easilly on the internet.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • For upcoming changes, You should consider making those 3 tabs (or whatever more You will have with new games) more visible and standing out, because right it looks like all topics hidden under those 3 tabs.
    • While not particularly active over the years, I've been around for as long as I could remember, so here are my 2 cents too. On top of what has already been said, I'd like to touch on a few thing that might be improved upon. While it is easy to notice and say "there's lack of engagement" or "community has outgrown the ganre", I've seen numerous forums get forgotten and die while others continue to thrive to this day. The main issue, in my humble opinion, is that the sector has been commercialised to an unsustainable extent. When nobody is willing to share anything, even if it is just a rework of an open-sourced or already-shared resource, the sense of "community" gets deminished. Now back on the pressing matter. From what I've seen, the lack of engagement could be circumvented with a redesign and functionality expansion that would/could/should include: - a built-in chat functionality. - incentives for engagement/interaction, ideas of which I'll list as separate pointers, as not to limit your creativity. But just as an example, from a more user/human perspective, having an easily identifiable way to get into "the club of the cool kids on the block", figuratively speaking, is an incentive on its own. - separation of the reputation into reactions and reputation. One to be used to posts, such as up-vote and what not, while the other to be awarded as means of appreciation. - automated ranks with actual benefits/perks, not like the current ones providing nothing. - the ability to hide text for user/group of users, not just premium/no premium. - increased visibility of the HOT topics and the RECENTLY ACTIVE threads/posts. Can be also expanded to most liked posts, etc. ps.: I'll update my post when I have some free time on my hands.
    • There was no way I didn't refunded or delivered files. I don't see You on my conrtact list on Discord, can You send me a message or at least tell me for what project was this updater? I always resolve if I can't deliver on time or customer bailes.
    • @rlfem123  I’m a web developer, and I work with technologies like Next.js and React. In the last 10 years, L2 Rankzone is the only one I’ve seen that actually did something different. All the others seem to have the same source code with different templates. L2 Hopzone also did an upgrade and, for the front end, is using Vue.js. Regarding web development, we have reached a point where you can easily create websites using libraries or frameworks. Simply pick one and start working. You will learn as you go. Personally, I prefer to build my back-end APIs in Laravel if it’s a big project since the ecosystem offers everything. For smaller projects, I choose Go. Then I use either React or Next.js to call my APIs, depending on the case. Next.js also supports Server-Side Rendering (SSR) if you want to hide some things from the client. Additionally, CSS libraries have almost everything you need nowadays to start building quickly with browser compatibility. You can seriously build an L2 website with ranks, a good design, and even a simple login/register system in just 3 days. Here are some CSS libraries I personally work with: https://tailwindui.com/components   https://ui.shadcn.com/   https://mui.com/material-ui/ Regarding the top websites i dont thing its worth the time and effort.  Its pretty simple to build one and the market is already bloated. In addition l2 is dying so i suggest to build top sites for many games.  THe main problem is not the build process rather the marketing one. You can build the most awesome website iin terms of functionality but if you marketing is week you wont exceed 10 concurrent users. 
  • Topics

×
×
  • Create New...