In this article I am going to show you how to create and execute a DOS (Disk Operating System) batch file to copy application's config file and place it in a different location of your hard disk. DOS batch files use the file extension ".bat". You can create batch file with extension .bat using DOS prompt where you can type your DOS commands or you can use any text editor and type your DOS command and you save that file with ".bat" extension. In our simple example we will use Notepad to create a batch file right on the desktop. The Notepad program is available on all Windows platforms.
Open a new Notepad file and save that file as Test.bat on your desktop. Add the code shown below to the file and save it.
This can be done step by step as follows-
Step 1
Click Windows key + R and type Notepad.
The Notepad program will start and it will show you an empty document with the title: "Untitled - Notepad".
Type the below highlight code or you can copy & paste the following highlighted code into the newly created notepad file:
xcopy C:\Santosh\MyProject\SPortal\SxxxxxPortal-DEV.config "C:\Configuration1\"
Step 2
- In the Notepad menu click: File – Save As, the Save As dialog shows up
- In the Save As dialog, select as Desktop
- In the File name field overwrite the file name by typing: Test.bat
- Click: Save
Execute a DOS batch - "Test.bat"
Minimize all windows and locate the icon called Test.bat on your desktop.
Double click the Test.bat icon.
Before Test.bat file executed:
After Test.bat file executed: