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

  
HOME ► Faq ► FAQ - Command Prompt - Windows 11, 10, etc. ► ««« »»»

Start batch files one after the other and not at the same time?


In order to start batch files one after the other and not at the same time, you should use the correct command, then it will work again with the command prompt!



Contents:

1.) ... Start programs or batch files one after the other in a batch file!
2.) ... Start programs or batch files at the same time in a batch file!
3.) ... What do I have to pay attention to with such batch files?


1.) Start programs or batch files one after the other in a batch file!

If you want the other batch files to start sequentially rather than at the same time, you can use the call function to pass control to the called batch file and wait for it to complete before calling the next one. Here is an example:

CALL


@echo off

call My-Batch-File-1.bat
call My-Batch-File-2.bat
call Program-1.exe

echo All batch files were executed one after the other.


In this example, the batch files My-Batch-File-1.bat, My-Batch-File-1.bat and Program-1.exe are called one after the other. The batch file waits until each called batch file completes before moving on to the next.

Here is another example with a backup of a folder with 7-Zip: 


set year=%date:~-4%
set month=%date:~-7.2%
set day=%date:~-10.2%
set date=%year%%month%%day%
set filter=* .bsc;*.pch;*.obj;*.ncb;*.ilk;*.tlb;*.tli;*.tmp;*.rsp;*.pgc;*.pgd;*.sbr;*.idb ;*.pdb;*.ipch;*.sdf;
Set folder=_cpp_m

D:\Port\7-Zip\7z.exe a -r -tzip %folder%_%Date%.zip %folder%\*.* -x!*.bsc -x!*.pch - x!*.ncb -x!*.ilk -x!*.tmp -x!*.rsp -x!*.pgc -x!*.pgd -x!*.sbr -x!*.idb -x! *.pdb -x!*.ipch

copy %folder%_%Date%.zip x:\BAC_C\%folder%_%Date%.zip



Here the "_cpp_m" folder is packed with "7-Zip\7z.exe" and copied to the external drive X: after execution. As a simple complete backup solution! 


2.) Start programs or batch files at the same time in a batch file!


If you want each batch file called to run in its own CMD window, you can use the start function instead of call. Here is an example:

START


@echo off

start program-1.exe
start my-batch-file-1.bat
start my-batch-file-2.bat
start program-2.exe

echo All batch files were started one after the other.



In this case, the batch files will open in separate CMD windows, but execution of the calling batch file will not be blocked. Note that the order in which the batch files finish is not fixed.



3.) What do I have to pay attention to with such batch files?


There are some important points to keep in mind when creating and using batch files:

Security: Batch files can execute system commands. You should therefore ensure that you use trustworthy sources and do not include malicious or unsafe commands in your batch files.

File extension: Batch files should have a “.bat” extension, e.g. E.g. “MyBatchFile.bat”.

Paths and filenames: Make sure paths and filenames are correct. Use absolute or relative paths as appropriate.
include.

Comments: Add comments to explain the code and make maintenance easier for future users or yourself.

Dependencies: If your batch file depends on other files or resources, make sure they are available and reachable.

Handling parameters: Pay attention to how you handle arguments and parameters in your batch file and check their validity.

Environment variables: Use environment variables to access system information or user information.

Testing: Before deploying your batch file to a production environment, test it thoroughly in a safe environment to avoid unwanted side effects.

Documentation: Document your batch files, especially if they are used by others.

Consider Compatibility: Note that batch files work on Windows systems but may not work on other platforms or operating systems.

Be careful with batch files as they can impact the system. Make sure you understand the impact of your batch files and use them consciously and responsibly
.

FAQ 156: Updated on: 11 May 2024 16:17 Windows
Windows-Console

Command Prompt to list files by date modified?


There are methods that allow you to search and view files in Windows by their modified date, and its quite easy In Windows, you can also search for files
Windows-Console

Batch file to rename files using regular expressions?


Batch files for renaming files using regular expressions are very popular, why not when renaming files can be so easy Contents: 1. Batch file to rename
Windows-Console

Mount VHD (Virtual Hard Disk) via Windows Command Prompt?


You can easily mount VHD Virtual Hard Disk using the Windows command prompt, for example if it is not possible in Disk Management Mounting VHD files from
Windows-Console

Creating simple volumes via command prompt, but how?


Creating a simple volume from the Windows command prompt using diskpart is a powerful way to manage your hard drives.  Contents: 1. Creating a simple volume
Windows-Console

Can I create striped volumes using a command line in Windows 11, 10...?


To create a striped volume using a command line, you need to open the command prompt CMD with administrative privileges and use the diskpart tool. Here
Windows-Console

Use XCOPY to backup files with examples in the CMD?


With XCOPY you can backup a directory and its subdirectories in several ways. Here are some examples: 1. Simple backup of a directory and its subdirectories:
Windows-Console

Use ROBOCOPY to backup files with examples in the CMD?


ROBOCOPY Robust File Copy is a powerful Windows command line tool used to copy files and directories. It is particularly well suited for creating backups

»»

  My question is not there in the FAQ
Asked questions on this answer:
Keywords: windows, console, start, batch, files, after, other, same, time, order, should, correct, command, then, work, again, with, Questions, Answers, Software




  

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

  + 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
  + TraceRouteOK
  + GetWindowText
  + AutoHideMouseCursor
  + Desktop.Calendar.Tray.OK
  + OK.Its.Raining.Men
  + Run-Command
  + MagicMouseTrails
  + CpuFrequenz
  + MultiClipBoardSlots
  + PAD-s


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

 © 2025 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu


► The left mouse button option Copy Move Confirm in Explorer! ◄
► Make an administrator account to a standard user on Windows 10/11! ◄
► To convert scanned page to PDF A4, A3, A2, A1 on Windows 11, 10, 8.1, ...! ◄
► Smart 3D Benchmark for MS Windows 11, 10, ... etc. and MS Server OS! ◄


This website does not store personal data. However, third-party providers are used to display ads,
which are managed by Google and comply with the IAB Transparency and Consent Framework (IAB-TCF).
The CMP ID is 300 and can be individually customized at the bottom of the page.
more Infos & Privacy Policy

....