Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Windows cmd.exe Command-Prompt ► ««« »»»

How to create a batch file on / for MS Windows?


Automation batch files for Windows are becoming more and more popular, it is even more important to correctly name and use the batch, which is often referred to as a script!   



A batch file is usually not a script but a batch processing file which is an executable text file, the commands are executed line by line, environment variables can be used here and programs can be started on MS Windows 11, 10, ... Desktop and all Microsoft server operating systems!

 
Content:

1.) ... Creating a batch file via the command prompt!
2.) ... Editing the batch files in the text editor!
3.) ... Use the help for internal commands and programs!
4.) ... Running the batch files on all MS Windows OS!
5.) ... What is the difference between scripts and batch files?
6.) ... What advantages do I have by using batch files!
7.) ... Tips and examples with batch files!



1.) Creating a batch file via the command prompt!

1. ►►  Start the text editor << As described here

2. Type the commands that are to be executed 

3. Here in the example the simple: ► Restarting of the file explorer

4. Save the file where it is needed for Execute 

(... see Image-1 Point 1 to 6)


(Image-1) Create a batch file on and for all MS Windows OS!
Create a batch file on and for all MS Windows OS!

-
▲ Back to the top ▲




2.) Editing the batch files in the text editor!

Editing the batch files is easy, any text editor can be used 

1. Start the text editor (Windows + R and command notepad)  

2. In the editor go to the menu ► File ► Open 

3. And enter the path of the batch files , for example:  C:\Test\Test_Batch.bat 


You can also start editing your batch file with Notepad from the command prompt by typing:


notepad C:\Test\Test_Batch.bat



You can also do it directly via the Run dialog:

Windows + R  notepad C:\Path_of\Test_Batch.bat

(... see Image-2 Point 1 to 3) 

(Image-2) Edit batch file under MS Windows OS!
Edit batch file under MS Windows OS!

-
▲ Back to the top ▲





3.) Use the help for internal commands and programs!



Use the help to achieve better / desired results for internal commands and programs, for most you can get help with the "help" command or "/?"  

For example:

help dir

 
or:  


dir /?

 

4.) Running the batch files on all MS Windows OS!

Executing the batch files on all MS Windows OS and other operating systems can be done from another batch file, which allows nesting and multiple use!
   
However, they are usually started via the command prompt, the Enter key in MS Explorer, or a simple mouse click!  

Adding to the startup folder is also possible to perform certain tasks at system startup!

For example: Add batch file to autostart to save time:
►►  Use batch file to start multiple programs!

Run example from command prompt 


C:>  C:\Test\Test_Batch.bat


In some cases you may need to run with elevated privileges, if that is the case, right click and select "Run as Administrator"

►►  Windows 11, 10, 8.1, ... Run programs as administrator?

5.) What is the difference between scripts and batch files?

There is much debate around the two terms, is a "batch file" a script or not. And when is it a script!  

The main difference is that a batch file is a list of commands to be executed, mostly doing the actual work in the programs that are controlled/used from the batch file,... while scripts have more own functions/ have sub-programs and sometimes carry out independent tasks. 

Batch files are very old, and can be seen as the first version of script files originating from MS-DOS and UNIX. But these are still used in all versions of Windows, including LINUX and MAC OS!

But you don't have to worry about whether a batch file is a script, the purpose is much more important! 


6.) What advantages do I have by using batch files!



It's primarily about automation, but also about saving time and avoiding errors when tasks have to be carried out again and again or have to be adjusted!

You can adapt a created bat file at any time, for example if you add further commands or change directories!


7.) Tips and examples with batch files!



►► Waiting for keyboard input Command prompt script?
►► Generate random numbers in command prompt or batch file!
►► Use batch file to start multiple programs!
►► How can I run commands in batch files at intervals?
►► Command line arguments in the command prompt with examples?
►► or in the Windows Console FAQ!



FAQ 138: Updated on: 12 October 2022 07:58 Windows
Windows-Console

Quickly disable windows user account via command line?


Very popular is the easy and fast deactivation of users via command line on MS Windows 11, 10, and MS Server 2022, 2019, operating systems Everyone
Windows-Console

What are command prompt internal commands?


The Windows CMD has internal commands that are in the command prompt itself, this does not start another exe that is started separately The external commands
Windows-Console

Looking for an example of a sub-function in a batch file?


Sometimes you just want a plain example of a subfunction ergo Sub-Routine in a command prompt batch file to understand how it works The CALL command starts
Windows-Console

Rename JPEG to JPG via command line, but how?


Sometimes you just want to rename JPEG to JPG to keep things in order, you can do that easily from the command line on MS Windows Desktop and Server OS
Windows-Console

Searching in files by string via command prompt?


The classic search in files for a character string via the command prompt is hardly used anymore, but it is still available on Windows 11, 10, In order
Windows-Console

Deleting files with no content using a batch file, but how?


Deleting files without content with a batch file, command prompt, or via the address bar in File Explorer is quite popular Here you can find out. that
Windows-Console

Is there a list of WMIC commands on MS Windows?


It is quite easy to have the MMIC commands listed on all Microsoft Windows desktop and MS servers and to obtain further information WMIC is deprecated The

»»

  My question is not there in the FAQ
Asked questions on this answer:
Keywords: windows, console, create, batch, file, automation, files, popular, important, correctly, name, which, often, referred, Questions, Answers, Software




    

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + ShortDoorNote
  + AutoHideDesktopIcons
  + BlankAndSecure
  + AlwaysMouseWheel
  + NewFileTime
  + DesktopClock3D
  + PointerStick
  + DesktopImages3D
  + WinPing
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Windows 2021 | Windows 10 | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2023 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.062


► I can not download the alternative command prompt for windows 11, 10, ... why? ◄

► Setup lock-out user account under Windows! ◄

► Help for Explorer in Windows-10/11! ◄

This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....