PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • 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
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.
WEBDEV - Server codeAjax This allows you to retrieve:
  • the return value of executable with the exeReturnValue constant.
  • the process identifier, also called PID with the exePID constant.
WEBDEV - Server code Remarks:
  • From Windows Vista, the applications may fail to start if the UAC mechanism is enabled. For more details, see remarks.
  • 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. For more details, see the Native 64-bit and native 32-bit help page.
Example
WEBDEV - Server code
// Lancement du bloc-notes avec le mode par défaut
ExeRun("NOTEPAD.EXE Lisezmoi.txt")
WEBDEV - Server code
// Lancement d'un programme avec un nom long comprenant des espaces
// Par exemple: Word avec "Mes documents" pour répertoire de travail
 
// Solution 1: Utilisation de la syntaxe spécifique des chaînes multilignes
// (évite de doubler ou tripler les guillemets)
IF ExeRun([
"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE"
], ...
exeActive, exeDontWait, SysDir(srMyDocuments)) = False THEN
Error(ErrorInfo())
END
 
// Solution 2: Doublement des guillemets
ExeRun("""C:\Program Files\Microsoft Office\Office12\WINWORD.EXE""", ...
exeActive, exeDontWait, SysDir(srMyDocuments))
WEBDEV - Server code
// Lancement d'applications avec un fichier en ligne de commande
// Nom de l'application à lancer
sNomAppli is string = "C:\Program Files\Adobe\Photoshop 6.0\Photoshp.exe"
// Nom de l'image à ouvrir
sNomImage is string = "C:\Users\Mon Nom\Pictures\Photos Immeubles\IMGP0993.JPG"
 
// Lancement équivalent à "Démarrer Exécuter"
// Il faut obtenir une chaîne de caractères contenant des "" du type:
// "C:\Program Files\Adobe\Photoshop 6.0\Photoshp.exe"
// "C:\Users\Mon Nom\Pictures\Photos Immeubles\IMGP0993.JPG"
IF ExeRun(StringBuild([
"%1" "%2"
], sNomAppli, sNomImage)) = False THEN
Error(ErrorInfo())
END
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"
<Mode>: Optional integer constant
Program launch mode (no action on 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.
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).
PHP This parameter is not available.
<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.
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.
PHP This parameter is not available.
WEBDEV - Server codeWindowsLinuxAjax

Starting a program and retrieving a value Hide the details

<Result> = ExeRun(<Program name> [, <Mode> [, <Element to return> [, <Working directory>]]])
<Result>: entier
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
Program launch mode (no action on 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
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)
<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.
<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, OrderLine allows you to retrieve the command line.
WEBDEV - Server codeWindowsLinuxAjax

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.
In addition, the Button control (if there is one) whose associated "Click" event contains a call to ExeRun must not be "Tab Stop" ("Accessible by TAB" in the "UI" tab of the control description).
WEBDEV - Server codeWindowsLinuxAjax

Return value of a WINDEV executable

A WINDEV executable can return a value. All you have to do is:
  1. Create an Integer variable global to the project.
  2. Initialize this variable with the value to return.
  3. Return this variable with the keyword RESULT in the project closing code.
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.
WEBDEV - Server codeWindowsAjax

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 can also use ShellExecute.
WEBDEV - Server codeWindowsLinuxAjax

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.
Component: wd260std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment