Skip to content

What is CALL Windows command?

The CALL command in Windows is used to call one batch program from another, allowing for the execution of multiple scripts in sequence. By using CALL, you can create more modular and organized scripts, improving the overall efficiency and maintenance of your batch files. This command is especially useful when you need to run a specific section of code multiple times within the same script or across different scripts. Additionally, CALL can pass control and parameters between batch files, enabling more complex and versatile scripting capabilities. Familiarizing yourself with the CALL command can enhance your batch scripting skills and help you streamline your automation tasks in Windows.

CALL Syntax:

Terminal window
tasklist [/s system [/u username [/p [password]]]] [/m [module] | /svc | /v]

CALL Options:

OptionDescription
/sSpecifies the name or IP address of a remote computer (do not use with /svc option).
/uSpecifies the user context under which the command should execute (do not use with /svc option).
/pSpecifies a password for the given username (if required) (do not use with /svc option).
/mDisplays all tasks with DLL modules loaded that match the given pattern.
/svcDisplays services hosted in each process (do not use with /s option).
/vSpecifies that information should be displayed in verbose mode.

Parameters:

ParameterDescription
systemThe name or IP address of a remote computer. This is optional.
usernameThe username for the specified user context. This is optional.
passwordThe password associated with the username. This is optional.
moduleSpecifies a DLL module to display information for. This is optional.

CALL Command Usage Examples:

Call a Batch File

Terminal window
call example.bat

Executes a batch file named “example.bat”.

Call a Command with Arguments

Terminal window
call dir /w

Executes the “dir” command with the “/w” argument to display wide list format.

Call a Program with Parameters

Terminal window
call program.exe -inputFile data.txt

Executes a program named “program.exe” with the parameter “-inputFile data.txt”.

Call a Command without Exiting the Current Batch Script

Terminal window
call another_script.bat

Executes another batch script named “another_script.bat” within the current batch script without exiting.

Call a Command with Redirection

Terminal window
call echo Hello > output.txt

Executes the “echo” command to write “Hello” to a file named “output.txt”.

:::tip
When using the `call` command in CMD, make sure to provide the correct path to the batch file or program you want to execute. Additionally, remember that using the `call` command allows you to return to the current batch file after executing the specified command or batch file.
:::
### How do I use call in CMD?
To use the call command in CMD, execute the following command:
```cmd
call C:\path\to\batchfile.bat

How can I pass arguments to a called batch file in CMD?

To pass arguments to a called batch file in CMD, use the following syntax:

Terminal window
call C:\path\to\batchfile.bat arg1 arg2

How to run a command in a separate command processor using call in CMD?

To run a command in a separate command processor using the call command in CMD, use the following syntax:

Terminal window
call cmd /c "command"

Can I call a function within a batch file using call in CMD?

Yes, you can call a function within a batch file using call in CMD. Use the following syntax:

Terminal window
call :functionName

How to use call with a label in CMD?

To use the call command with a label in CMD, execute the following command:

Terminal window
call :labelName

How do I use call to run a program in CMD?

To use the call command to run a program in CMD, execute the following command:

Terminal window
call program.exe

Is it possible to call another batch file and return to the original file in CMD?

Yes, it is possible to call another batch file and return to the original file in CMD using the call command. Use the following syntax:

Terminal window
call C:\path\to\another\batchfile.bat

How to call a subroutine within a batch file using call in CMD?

To call a subroutine within a batch file using the call command in CMD, use the following syntax:

Terminal window
call :subroutineName

Applications of the CALL Command

  • Running a batch file from another batch file
  • Calling a subroutine within a batch file
  • Invoking a command or script with parameters from a batch file