hello friends,
I need to write a batch file, but I am completely unaware of how to start with it. Can anybody please help me providing information on how to write a batch file ?
thanks a lot....
hello friends,
I need to write a batch file, but I am completely unaware of how to start with it. Can anybody please help me providing information on how to write a batch file ?
thanks a lot....
Follow the instructions below to Write a Batch File :-
- Open NotePad > go to File > select Save As > choose a file name > select desktop as a location to save afile but don't click Save yet…
- Click on the dropdown menu next to "File name" and select "All files" instead of “.txt”
- Before you save , add .bat to the end of your file name. For example, you would type example.bat.
- Click on Save.
- A file name in the title of Windows Notepad should appear. Make sure that it reads as example.bat—not example.bat.txt.
Now you are ready to create your batch file.
- Type "@echo off" on the first line of your batch file. This will prevent any spaces in the batch file to be read by the program when executed.
- Enter your commands. The following example will show you how to create a batch file that will automatically load wikiHow.com using Internet Explorer.
- @echo off.
- REM The following will open website.com in a new Internet Explorer window.
- "start Iexplore.exe www.website.com"
- REM The following will open website.com in your default browser, but if it is IE and you have another IE window open, then it will hijack that window.
- "start www.website.com"
- Save the file by "File > Save" and type in "website.bat".
- Run the file by double clicking the file on your desktop.
source - http://www.wikihow.com/Write-a-Batch-File
To create a basic batch file in MS-DOS, follow the steps below --
Open an MS-DOS command window.
At the MS-DOS prompt, type: edit test.bat and press enter.
A blue screen should appear. Within the screen, type:
pause
dir c:\windows
dir c:\windows\system
Click File and choose Exit.
When prompted to save, click "Yes." Users who do not have a mouse cursor can accomplish this same task by pressing ALT+F to access the file menu, then pressing "X" to exit, and pressing enter to save changes.
Once you are back at the MS-DOS prompt, type: test and press enter. This will execute the test.bat file and begin running the file. Because the first line is pause, you will first be prompted to press a key. Once you press a key the batch file will run line-by-line; in this case, listing the files in the windows and windows\system directories.
A Windows user can still use the above MS-DOS steps if they wish to create a batch file. If, however, you're more comfortable using Microsoft Windows or your operating system, you can use any text editor, such as Notepad or Wordpad, to create your batch files, as long as the file extension ends with .bat. In the below example we use the Windows notepad to create a batch file.
Click Start -- Click Run -- Type: notepad -- press Enter.
Once notepad is open, type the below lines in the file or copy and paste the below lines into notepad.
@echo off
echo Hello this is a test batch file
pause
dir c:\windows
Click File -- Save and browse at the location where you want to save the file.
For the filename, type "test.bat" and if your Windows version has a "Save as type" option, choose "All files". Otherwise it will save a file as a text file. Once everything is done, click on Save button and exit Notepad.
Now, simply double-click or run the file like any other program for running a batch file. Once a batch file has completed running, it will close the Window automatically.
source - http://www.wikihow.com/Write-Batch-Files
Bookmarks