Below are steps on how to make a batch file on any computer running a Microsoft operating system (e.g., MS-DOS or any version of Windows).
Clients are similar: sitting in their own local 'game' directory, scan for incoming updates (files) based, again, on timestamp, oldest first. Read the file, present the data to the player, and wait for his response, then build a response file (after validation etc.) and send response back to the server's IP.
Creating a batch file in Microsoft Windows
In Windows, you can create a batch file using the steps below or the steps mentioned in the MS-DOS command line section. If you are more comfortable with Microsoft Windows, 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 example below, we use the Windows Notepad to create a batch file.
- Click Start.
- Type Notepad in the Run box and press Enter.
- Once Notepad is open, type the following lines or copy and paste them.
- Click File and then Save, and then navigate to where you want to save the file. For the file name, type test.bat and if your version of Windows has a Save as type option, choose All files, otherwise it saves as a text file. Once you have completed these steps, click the Save button and exit notepad.
- To run the batch file, double-click it like any other program. Once the batch file has completed running, it closes automatically.
See our what commands are available in a batch file page for commands that can be added to a batch file.
Creating a batch file in MS-DOS
To create a batch file in MS-DOS or the Windows command line, follow the steps below.
NoteNew versions of Windows or computers running a 64-bit version of Windows no longer support the edit command, which means these steps no longer work. Use the above steps if you are running the latest version of Windows.
- Open an MS-DOS command window or load MS-DOS.
- In the MS-DOS prompt, type: edit test.bat and press Enter.
- If typed correctly, you should now see a blue edit screen. In the edit screen, type:
- Once these three lines are entered, click File and choose exit; when prompted to save, click Yes. Users who do not have a mouse can accomplish this same task by pressing Alt+F to access the file menu, and then X to exit. Press Enter to save changes.
- Once you are back at the MS-DOS prompt, type: test and press Enter to execute the test.bat file. Because the first line is a pause, you will first be prompted to press a key. Upon doing so, the batch file runs line-by-line; in this case, listing the files in the Windows and Windowssystem directories.
If you want to add more lines to this batch file, type edit test.bat to open the file for editing.
Additional information about the MS-DOS edit command is on our edit command page. Some versions of MS-DOS and bootable diskettes may not have the edit command. If this the case, you would either need to obtain the edit.com file or use the copy con command.
TipSee our what commands are available in a batch file page for commands that can be added to a batch file.
Additional information
Furthermore in this tutorial we will explain way to create batch to delete file automatically using command line. This is useful if you have limited space on a HDD and need to delete files on some folders that populated automatically. In my case SQL backups folder.
After tutorial where we created batch to zip files, this is other useful tutorial for your daily jobs.
You will need to delete those files manually every day and this is not good practice. On the other hand you can create script to delete file automatically. All of that without installing any Third-party software. In fact this example will show steps for creating batch file and you can use Task Scheduler to run.
Other useful batch tutorial:
- Script to zip files – Script to zip files using cmd command.
- Delete file older than. – Delete file using command line.
- Batch to delete file older than– Delete files older than 7 days using batch and script.
Batch to delete file automatically.
Furthermore we will explain two methods:
- Batch file to delete file based on extension of the file.
- Script file to delete all files
Batch to delete file based on extension.
In fact Batch files are scripts that can run to perform tasks on you system. They are the best ways to save time. In fact we will delete files on specific folders. For example, we will tell the batch file to delete .txt files that are located in the Test folder.
Create a text file and copy the below command line:
Save like a delete.bat. Save anywhere except D:Test_1Test .
del “D:Test_1Test*.txt”The basic command locates the folder.
/s parameter will delete all files contained in the directory subfolders. If you do not want to delete files from subfolders, remove /s parameter.
/f parameter ignores any read-only setting.
/q “quiet mode,” meaning you won’t be prompted Yes/No
Batch to delete file
Note! Remember to change the directory to match your computer.
Run as Administrator and all files with defined extension will deleted.
Script file to delete all files.
As a result we will tell the Script file to delete all files that are located in the Test folder.
At this point run as Administrator and all files located in the “Test” folder will deleted.
Also you can use Task Scheduler to create scheduled task.
————————————————————————————–