ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WINDEV 2025 feature!
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Command functions
  • Properties specific to Command variables
  • Functions that use Command variables
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Command type defines all the advanced characteristics of a command used for an executable file. You can define and change the characteristics of this command using different WLanguage properties.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Execute the command 'C:\Path\MyProgram.exe -opt1=val1'

// Define the command
MyCommandToExecute is Command
// Executable to run
MyCommandToExecute = "C:\Path\MyProgram.exe"
// Arguments to pass to the executable
MyCommandToExecute.Arguments = "Argument1"
// Open streams
MyCommandToExecute.Streams = cmdStandardInput + cmdStandardOutput
// Add an argument to the command line
CmdAddArgument(MyCommandToExecute, "Argument2")
// Add an option to the command line
CmdAddOption(MyCommandToExecute, "opt1", "val1")

// Execute command 
CmdExecute(MyCommandToExecute, False)
// Write to standard input (possible because the stream is open)
CmdWriteStandardInput(MyCommandToExecute, "Write test" + CR)
// Get return code of the command (value received when the command finishes executing)
code is int = CmdGetExitCode(MyCommandToExecute, True)
// Read from standard output (possible because the stream is open)
stdout is string = CmdReadStandardOutput(MyCommandToExecute)
// Read from error output (not possible because the stream is not open)
// Error message: 'STDERR' is not open.
stderr is string = CmdReadErrorOutput(MyCommandToExecute)
Properties

Properties specific to Command variables

The following properties can be used to define the characteristics of Command variables:
Property nameType usedEffect
ArgumentsCharacter stringArguments to pass to the command.
The contents of this property replace all previously defined arguments and options.
AutoTerminateBoolean
  • True (default): The executable associated with the command stops if the variable is destroyed or reset to zero.
  • False: The executable associated with the command continues to run even if the variable is destroyed or reset ro zero.
Note: You can force the executable associated with a command to stop with CmdKill.
Note: This property is only available from version 2025 Update 1.
ExecutableCharacter stringPath to the executable associated with the command.
IDIntegerProcess identifier (Handle or pid).
This property is available in read-only mode.
RedirectStdErrToStdOutBoolean
  • True to redirect the STDERR stream to STDOUT.
    Please note: Both STDOUT and STDERR must be open.
  • False otherwise.
StreamInteger constantStream to be opened:
  • cmdStandardInput: Standard input stream (StdIn).
  • cmdErrorOutput: Standard error stream (StdErr).
  • cmdStandardOutput: Standard output stream (StdOut).
By default, all streams are open.
Remarks

Functions that use Command variables

New in version 2025
CmdAddArgument
Adds an argument to a command to be executed in console mode.
New in version 2025
CmdAddOption
Adds an option to the command to be executed in console mode.
New in version 2025
CmdExecute
Executes a command in console mode.
New in version 2025
CmdGetExitCode
Gets the exit code of the command executed in console mode, i.e. the value returned when the command finishes executing.
New in version 2025
CmdIsRunning
Indicates whether the executable associated with a command is currently running.
Note: This function is only available from version 2025 Update 1.
New in version 2025
CmdKill
Forces the termination of a running executable associated with a command.
Note: This function is only available from version 2025 Update 1.
New in version 2025
CmdReadErrorOutput
Reads error output data for the command executed in console mode.
New in version 2025
CmdReadStandardOutput
Reads standard output data, for the command executed in console mode.
New in version 2025
CmdWriteStandardInput
Writes data to the standard input of the command executed in console mode.
Minimum version required
  • Version 2025
Comments
Click [Add] to post a comment

Last update: 03/14/2025

Send a report | Local help