Mumbai, , India
Software Engineering, Android, English Language
0 टिप्पणी करें | 22 लोगो ने देखा है | 19 अगस्त 13  | Abdul Aziz Ansari
Batch Programming for Windows
First of all you should know what is quotBatch filequot A batch file is usually a sequence or set of commands that run step by step, these commands are similar to quotcmdquot commands but they can execute continuously without entering each command again and again. In cmd or also aka command prompt, we enter a command and output is displayed again we enter a command again output is displayed everyone time the same procedure is repeated, but if we want to run more than one command or different commands then we can do it by batch programming. In DOS systems the batch file ends with quot.batquot extension, e.g- test.bat etc... Many operating systems use the terms quotcommand filequot or quotshell scriptquot in place of batch file. You can use any quottext editorquot e.g- notepad,notepad,word etc. Open notepad or any text editor Now here is the first batch file example- echo off echo HI and saved it as test.bat, now double-click on it , u will not be able to see the output, bcz it is displayed and vanishes very fast so write down quotpausequot in the end so the program will be- echo off echo HI pause now run it You can now see the result, after pressing any key the quotconsole screenquot will be vanished Now we should understand the program step by step here quotquot is predefined, by using quotecho off quot the current location of the file is not shown on the console screen you can also try quotecho onquot, try it in your program and notice the changes, quotechoquot is used to display the text on the console screen e.g- echo off echo Hi echo Learning Batch Programming echo end echo Interesting echo blah blah pause you can also delete or create new folders or files through batch file To delete a text file assume that file name is quottest.txtquot echo off del test.txt this batch file will delete the text file, suppose if that quottest.txtquot file is placed on desktop then to delete the file we will have to write it - echo off cd desktop del test.txt You can also create or delete folders echo off mkdir aaa //for creating folder aka directory to delete a directory or folder echo off rmdir aaa Remember the batch file works default at the location where it is placed, if you placed the batch file on the desktop and the folder in the same directory or desktop then that folder will be deleted, if you change the location of the folder to be deleted then error msg will be shown, then you will have to provide the exact location of that folder or directory. OK now i am posting some more commands related to deleting and creating folders etc which u can use in your batch file - md name //create a directory with chosen name rd name //delete a directory with chosen name, The dir most be Empty.. del PatchName //Delete file/files If your Batch file is in the same dir as the file you wanna delete, Then you only need to write the Filename del MyFile.exe, But if it Aint, You need to write the path to del cwindowstemp.dat call //Runs an other .Bat file, And when that file is Done, Your file will continue after that call command.. dir //List all the files in your directory.... dir gt info.txt // This Command 39gt39 Doesacutent Print the output to the screen, it print it to info.txt ... del .exe //deletes All exe-files, u can use del cwindows.exe . //all files .. .dll //all dll files e.t.c copy file1 tile2 //just coping a file ... if you are trying to copy a file to an existing file, it will ask if u realy want to owerwrite it .. But if you using copy a.exe b.exe /y It wonacutet ask. So just put an /y at the end ... cls //Clear the screen ... pause // Print the Text Press any key.. And waiting for A key to be pressed ... Now I will tell you about the looping to loop a program or if you want that a certain set of commands or instructions should repeat until not stopped then u can do it as - echo off loop echo Hi goto loop here quotloopquot is just like a pointer anything after this pointer and before quotgotoquot will be repeated. You can use any word and even numbers like echo off 1 echo Hi goto 1 Now next time I will tell you about the quotvirusesquot , they are also batch files..... Till then bye...

    • इस ब्लॉग के लिए सामाजिक शेयर

पोर्फोलिओ और ब्लॉग
Abdul Aziz Ansari विभिन्न कंपनियों का अनुसरण करता है, ये कंपनियां और नियोक्ता Abdul के फिर से शुरू देख सकते हैं
सबसे अच्छा नौकरी के अवसर पाने के लिए अपना फिर से शुरू करें अपलोड करें

मुफ्त रजिस्टर करें!