Create Basic Windows 10 Batch File
Create Basic Windows 10 Batch File
1. Open Start.
2. Search for Notepad and click the top result to open the text editor.
3. Type the following lines in the text file to create a batch file:
4. @ECHO OFF
5. ECHO Congratulations! Your first batch file was
executed successfully.
6. PAUSE
1. Open Start.
2. Search for Notepad and click the top result to open the text editor.
3. Type the following lines in the text file to create a more advanced
Windows 10 batch file:
4. @ECHO OFF
5. :: This batch file details Windows 10, hardware,
and networking configuration.
6. TITLE My System Info
7. ECHO Please wait... Checking system information.
8. :: Section 1: Windows 10 information
9. ECHO ==========================
10. ECHO WINDOWS INFO
11. ECHO ============================
12. systeminfo | findstr /c:"OS Name"
13. systeminfo | findstr /c:"OS Version"
14. systeminfo | findstr /c:"System Type"
15. :: Section 2: Hardware information.
16. ECHO ============================
17. ECHO HARDWARE INFO
18. ECHO ============================
19. systeminfo | findstr /c:"Total Physical Memory"
20. wmic cpu get name
21. wmic diskdrive get name,model,size
22. wmic path win32_videocontroller get name
23. :: Section 3: Networking information.
24. ECHO ============================
25. ECHO NETWORK INFO
26. ECHO ============================
27. ipconfig | findstr IPv4
28. ipconfig | findstr IPv6
29. START https://support.microsoft.com/en-
us/windows/windows-10-system-requirements-6d4e9a79-
66bf-7950-467c-795cf0386715
30. PAUSE
1. Open Start.
2. Search for Notepad and click the top result to open the text editor.
3. Type the following command to map a network drive in the text file:
4. net use z: \\PATH-NETWORK-SHARE\FOLDER-NAME
/user:YOUR-USERNAME YOUR-PASSWORD
Source: Windows Central
In the command, replace the \PATH-NETWORK-SHARE\FOLDER-
NAME for the network path for the folder you want to mount on the
computer, and YOUR-USERNAME YOUR-PASSWORD with the
username and password that grants access to the network files.
This example maps a network folder as a drive inside File Explorer using
the "Z" drive letter:
net use z: \\10.1.4.118\shareone
We only demonstrate a script with a single command, but you can include
as many as you like, as long as you write them one per line.
Command Prompt
To run a script file with Command Prompt on Windows 10, use these steps.
1. Open Start.
2. Search for Command Prompt, right-click the top result, and select
the Run as administrator option.
3. Type the following command to run a batch file and press Enter:
C:\PATH\TO\FOLDER\BATCH-NAME.bat
In the command, make sure to specify the path and name of the script.
This example runs the batch file located in the "scripts" folder inside the
"Downloads" folder:
C:\Users\useraccount\Downloads\first_basic_batch.bat
S
ource: Windows Central
After you complete the steps, the console will return the results, and the
window won't close even if the script does not include the "PAUSE"
command since you are invoking the script from within a console window
that you opened manually.
File Explorer
To run a batch file with the Windows 10 File Explorer application, use these
steps:
1. Open File Explorer.
2. Open the folder containing the batch file.
3. Double-click the script file to run it.
4. (Optional) If a command requires administrator privileges, you will
need to run the script as an admin by right-clicking the file and selecting
the Run as administrator option.
1. Open File Explorer.
2. Open to the folder containing the batch file.
3. Right-click the batch file and select the Copy option.
4. Use the Windows key + R keyboard shortcut to open
the Run command.
5. Type the following command:
shell:startup
1. Open Start.
2. Search for Task Scheduler and click the top result to open the app.
3. Right-click the "Task Scheduler Library" branch and select the New
Folder option.
4. Confirm a name for the folder — for example, MyScripts.
Quick note: It is not a requirement to create a folder, but it's recommended
to separate the system and your personal tasks.
5. Click the OK button.
6. Expand the "Task Scheduler Library" branch.
7. Right-click the MyScripts folder.
8. Select the Create Basic Task option.
Sou
rce: Windows Central
Quick note: On Windows 10, the Task Scheduler allows you to choose
from different triggers, including a specific date, during startup, or when a
user logs in to the device. In this example, we will select the option to run a
task every month, but you may need to configure additional parameters
depending on your situation.
13. Click the Next button.
14. Use the "Start" settings to confirm the day and time to run the task.
15. Use the "Monthly" drop-down menu to pick the months of the year to
run the task.
S
ource: Windows Central
16. Use the "Days" or "On" drop-down menu to confirm the days to run
the task.
Sour
ce: Windows Central
21. Click the Finish button.
Once you complete the steps, the task will save and run the script on your
specified schedule.
The above instructions are meant to schedule only a basic task. If you want
to create a more customizable task with the Task Scheduler, use these
steps.
We're focusing this guide on Windows 10, but batch files have been around
for a long time, which means that you can refer to these steps if you are still
on an older version, including Windows 8.1 or Windows 7.