Saturday, October 27, 2012

Learn batch programming ( noob way )




Many of you may think batch programming is hard... but its not, actually its simplest , you dont need to compile the source here... according to me its not actually PROGRAMMING....!!  just a set of commands .... instead of writing all commands in command prompt just run a simple batch file....  after all this not only you can create a simple virus but also u will know how it works..... I only teach here necessary commands not any useless lines... :)



Icon for ".bat" file in Win7/Vista                            

Icon in Win XP




What is batch scripting ?
- it is set of commands  in ".bat" file written with any editor for Windows OS.... bat file wont work for Linux environment... shell is for linux...

Getting started....
@ You need a good text editor.... you can use Notepad.... or Notepad++  ( my fav. , easy to detect errors)

@ every time when i say save, you need save it as "blabla.bat" not "txt"

    say it clearly : after editing in editor, click save/save as , a dilog box will   appear click save type as
    { All types (".") } NOT "Text file (".txt") as show below


     

give name as you want "@#$%$.bat" not extension must be .bat....

@ simply double click to run it


Step-1:

basics commands :


 # cd  :  means Change Directory :Used to navigate to different      directories...
          ex cd home changes location to home folder from current folder

 # del  :  used to delete any specific file... located in current tree(dir)
          use switches for more option :
          /P  Give a Yes/No Prompt before deleting. 
          /F  Ignore read-only setting and delete anyway (FORCE) 
          /S  Delete from all Subfolders
          /Q  Quiet mode, do not give a Yes/No Prompt before deleting.
          /A  Select files to delete based on file_attributes

          Ex: make a bat file with following lines

               @echo off

               del /Q *.txt

save as anything.bat... run in any directory will delete all text files in that dir..... /q or /Q (batch is not case sensitive) switch don't ask you before deleting... u can use other switches as well.....


# echo : if u are femilar with C programming.... printf equivalent in batch is                  
            "echo" anything after echo 
            will be printed in command prompt... leave a space after echo.... and         
            type as you wish

            Ex:[echo tricks and tips blog ] will display tricks and tips.... you can   
                use special characters as well...

             "echo." used for blank line

             
             Learn batch programming - 2

1 comment: