PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Using a command line
  • Using the exeActive constant
  • Return value of a WINDEV executable
  • Starting an application in WEBDEV server code
  • Starting an application in Windows Vista (and later)
  • Various
  • Equivalence
  • Operating mode in GO mode and at run time
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Starts the execution of a program (an executable for example) from the current application.
WINDEVWEBDEV - Server codeReports and QueriesWindows MobileJavaAjaxUser code (UMC) This allows you to retrieve:
  • the return value of executable with the exeReturnValue constant.
  • the process identifier, also called PID with the exePID constant.
WINDEVWEBDEV - Server code Notes:
  • From Windows Vista, the applications may fail to start if the UAC mechanism is enabled. See remarks for more details.
  • In 64-bit Windows, the access to a system directory from a 32-bit executable can be performed in a directory that differs from the expected one. See Native 64-bit and native 32-bit for more details.
Versions 22 and later
Android This function is now available for the Android applications.
Android Widget This function is now available in Android Widget mode.
New in version 22
Android This function is now available for the Android applications.
Android Widget This function is now available in Android Widget mode.
Android This function is now available for the Android applications.
Android Widget This function is now available in Android Widget mode.
Example
WINDEVWEBDEV - Server code
// Start Notepad in default mode
ExeRun("NOTEPAD.EXE Readme.txt")
WINDEVWEBDEV - Server code
// Start a program with long name containing space characters
// For example: Word with "My documents" as working directory

// Solution 1: Using the syntax specific to the multiline strings
// (to avoid doubling or tripling the quotes)
IF ExeRun([
"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE"
], ...
exeActive, exeDontWait, SysDir(srMyDocuments)) = False THEN
Error(ErrorInfo())
END

// Solution 2: Doubling the quotes
ExeRun("""C:\Program Files\Microsoft Office\Office12\WINWORD.EXE""", ...
exeActive, exeDontWait, SysDir(srMyDocuments))
WINDEVWEBDEV - Server code
// Start applications with a file in command line
// Name of application to start
sAppName is string = "C:\Program Files\Adobe\Photoshop 6.0\Photoshp.exe"
// Name of the image to open
sImageName is string = "C:\Users\My Name\Pictures\Buildings\IMGP0993.JPG"

// Equivalent to "Start Run"
// We must get a character string containing "" such as:
// "C:\Program Files\Adobe\Photoshop 6.0\Photoshp.exe"
// "C:\Users\My Name\Pictures\Buildings\IMGP0993.JPG"
IF ExeRun(StringBuild([
"%1" "%2"
], sAppName, sImageName)) = False THEN
Error(ErrorInfo())
END
Versions 22 and later
AndroidAndroid Widget
// Start Google Maps
ExeRun("com.google.android.apps.maps")
New in version 22
AndroidAndroid Widget
// Start Google Maps
ExeRun("com.google.android.apps.maps")
AndroidAndroid Widget
// Start Google Maps
ExeRun("com.google.android.apps.maps")
Syntax

Running an executable (in locking or non-locking mode) Hide the details

<Result> = ExeRun(<Program Name> [, <Mode> [, <Wait for End> [, <Working Directory>]]])
<Result>: Boolean
  • True if the program was started,
  • False otherwise. ErrorInfo returns more details about the error.
PHP This function returns no result.
<Program Name>: Character string
Name of program to start with its path and/or the parameters that must be passed to the program (if necessary).
  • If no path is specified, the program is sought in the current directory, then in the Windows directory and in the directories accessible by PATH.
  • If the executable corresponds to a long name with space characters, the following syntax must be used:
    <Program Name> = " " " Long_name_with_spaces" " Command_line"
Versions 22 and later
AndroidAndroid Widget Full name of the application to start (with the package name).
Example: to start the Google Maps application, <Program Name> corresponds to: "com.google.android.apps.maps"
New in version 22
AndroidAndroid Widget Full name of the application to start (with the package name).
Example: to start the Google Maps application, <Program Name> corresponds to: "com.google.android.apps.maps"
AndroidAndroid Widget Full name of the application to start (with the package name).
Example: to start the Google Maps application, <Program Name> corresponds to: "com.google.android.apps.maps"
<Mode>: Optional integer constant
Mode used to start the program (no action on the DOS programs).
exeActive
(Default value)
The program run is active, it "takes control" over the current program.
exeIconizeThe program run is inactive and it is minimized.
AndroidAndroid Widget Windows MobileJava This constant is not available.
exeInactiveThe program run is inactive: it is run while the current program keeps focus.
AndroidAndroid Widget Java This constant is not available.
exeMaximizeThe program run is active, it "takes control" over the current program (the execution window is maximized).
AndroidAndroid Widget Java This constant is not available.
PHP This parameter is not available.
AndroidAndroid Widget Java The program run is always active: it is run by "taking control" over the current program.
<Wait for End>: Optional Boolean constant
Configures the time-out before resuming the execution of the current program:
exeWaitThe current program resumes its execution when the program run is over.
AndroidAndroid Widget The application can be started in non-locking mode only. A fatal error occurs if the exeWait constant is used.
exeDontWait
(Default value)
The current program and the program run are run in parallel.
PHP This parameter is not available.
<Working Directory>: Optional character string
Working directory of application to start.
AndroidAndroid Widget PHP This parameter is not available.
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxWindows MobileJavaAjaxUser code (UMC)

Starting a program and retrieving a value Hide the details

<Result> = ExeRun(<Program Name> [, <Mode> [, <Element to Return> [, <Working Directory>]]])
<Result>: Integer
Sought value:
  • Return value of the executable if <Element to Return> corresponds to the exeReturnValue constant.
  • PID of the executable if <Element to Return> corresponds to the exePID constant.
ErrorInfo is used to find out whether an error occurred.
<Program Name>: Character string
Name of program to start with its path and/or the parameters that must be passed to the program (if necessary).
  • If no path is specified, the program is sought in the current directory, then in the Windows directory and in the directories accessible by PATH.
  • If the executable corresponds to a long name with space characters, the following syntax must be used:
    <Program Name> = " " " Long_name_with_spaces" " Command_line"
<Mode>: Optional integer constant
Mode used to start the program (no action on the DOS programs).
exeActive
(Default value)
The program run is active, it "takes control" over the current program
exeIconizeThe program run is inactive and it is minimized
Windows Mobile This constant is not available.
exeInactiveThe program run is inactive: it is run while the current program keeps focus
exeMaximizeThe program run is active, it "takes control" over the current program (the execution window is maximized)
Java This parameter is ignored. The program run is active, it "takes control" over the current program.
<Element to Return>: Optional constant
Configures the function result:
exeReturnValueThe current program resumes its execution when the program run is over. <Result> corresponds to the return value of executable.
exePIDThe current program and the program run are run in parallel. <Result> corresponds to the identifier of created process (also called PID) if the executable was successfully run, 0 if an error occurred.
This identifier can be used in some APIs for example.
Java This constant is not available.
<Working Directory>: Optional character string
Working directory of application to start.
Remarks

Using a command line

To pass parameters in command line to the executable run, you must specify the name and full path of the executable to run.
If the program run was developed with WINDEV, CommandLine allows you to retrieve the command line.
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxWindows MobileJavaAjaxUser code (UMC)

Using the exeActive constant

If the process where the application is run (with the exeActive constant) runs a code allowing the calling program to regain focus, the called program loses control.
In order for the called program to keep focus, you must not:
  • call another window or dialog box after the call to ExeRun,
  • call ReturnToCapture after ExeRun.
Furthermore, the possible button whose process contains a call to ExeRun must not be a "Tab Stop" button ("Accessible by TAB" in the "Details" tab of control description).
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxWindows MobileJavaAjaxUser code (UMC)

Return value of a WINDEV executable

A WINDEV executable can return a value. To do so:
  1. Create an Integer variable global to the project.
  2. Initialize this variable with the value to return.
  3. Return this variable with the RESULT keyword in the closing code of project.
WEBDEV - Server codeAjax

Starting an application in WEBDEV server code

ExeRun is run on the server, therefore the started application is run on the server.
By default, the application is only visible in the task manager because it is started from a service that does not interact with the Windows desktop.
In order for the program run to be visible on the server, the option "Allow the service to interact with the desktop" must be checked in the properties of the WEBDEV service.
WINDEVWEBDEV - Server codeReports and QueriesWindowsAjaxUser code (UMC)

Starting an application in Windows Vista (and later)

If the UAC is enabled, the application that is using ExeRun to start another application must have higher rights than the application that is started.
For example, a first application started with the administrator rights can start a second application that requires no specific rights.
If the second application requires greater rights than the application that starts it, the second application may fail to start. Windows proposes to enable the management of compatibility with Windows Vista. If the management of compatibility is enabled, the second application will be run during its next startup. You also have the ability to use ShellExecute.
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxWindows MobileJavaAjaxUser code (UMC)

Various

  • ExeRun does not modify the current directory. The current directory before running ExeRun is identical to the current directory after running ExeRun.
  • If the program run ignores the specified runtime mode, the program is run in exeActive mode.
Windows Mobile

Equivalence

The operating mode of ExeRun is equivalent to the operating mode of ceRunExe.
The only difference is:
  • ceRunExe runs a program on the Pocket PC from a WINDEV application.
  • ExeRun runs a program on the Pocket PC from a WINDEV Mobile application.
Windows Mobile

Operating mode in GO mode and at run time

In GO mode (simulation on the development computer), the application to start must be found on the development computer.
At run time, the application to start must be found on the Pocket PC.
The differences between GO mode (simulator) and real use are presented in Differences between GO mode and real use.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Windows Mobile wp230std.dll
Java wd230java.jar
Linux wd230std.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Video Exemplo ExeRun
https://youtu.be/_MqM-jTn3XQ
amarildo
Oct. 26 2018
Executar um aplicativo passando parametros para ele
bStarted = ExeRun("C:\Windows\System32\calc.exe", exeActive, exeDontWait, "C:\Windows\System32\")

IF bStarted > 0 THEN

Info("Programa de calculadora executado!")

ELSE

Error("Programa de calculadora não executado. Favor Ligar para o suporte!")

END
BOLLER
Jan. 25 2017
Exemplo 2 ExeRun
Exempo ExeRun

ExeRun("matos_utilitarios.exe")
//Blog com video e exemplo

http://windevdesenvolvimento.blogspot.com.br/2016/06/curso-windev-funcoes-exe-windows-004.html
https://www.youtube.com/watch?v=I7RyOO1v5oI
De matos AMARILDO
Jun. 01 2016
Exemplo ExeRun
Exemplo ExeRun


// Iniciar um programa com nome comprido que contenham caracteres de espaço
// C:\Program Files\Microsoft Office\Office12\WINWORD.EXE
IF ExeRun([
"C:\Program Files (x86)\OpenOffice 4\program\soffice.EXE"
], ...
exeActive, exeDontWait, SysDir(srMyDocuments)) = False THEN
Error(ErrorInfo())
END

// Iniciar um programa com nome comprido que contenham caracteres de espaço
// C:\Program Files\Microsoft Office\Office12\WINWORD.EXE
ExeRun("""C:\Program Files (x86)\OpenOffice 4\program\soffice.EXE""", ...
exeActive, exeDontWait, SysDir(srMyDocuments))
// Iniciar aplicações com um arquivo em linha de comando
nome_aplicativo is string = "MSPAINT.EXE" // // "C:\Program Files\Adobe\Photoshop 6.0\Photoshp.exe"
nome_imagen is string = "E:\_IMAGENS\SERVICOS\Windev20\windev-20.JPG"
IF ExeRun(StringBuild([
"%1" "%2"
], nome_aplicativo, nome_imagen)) = False THEN
Error(ErrorInfo())
END

// observacao..
// Esses Parametros poderiam ser passado de fora do programa commandline
// exemplo: programa_exe_run mspaint.exe E:\_IMAGENS\SERVICOS\Windev20\windev-20.JPG
// Para saber mais sobre commandline assiste abaixo blog
// http://windevdesenvolvimento.blogspot.com.br/2015/02/windev-commandline-receber-parametros.html

//Blog com video e exemplo :

http://windevdesenvolvimento.blogspot.com.br/2015/02/windev-exerun.html
De matos AMARILDO
Apr. 27 2016