Shell Function

Official Content
This documentation is valid for:

Runs an executable within the operating system.

Syntax

&ret = Shell(‘program.exe, [ Modal ] )
 
Type Returned:
Numeric
 
Where:
Modal  Numeric optional parameter. It indicates whether to wait the launched program to finish or to continue executing it. 
If we pass: 

  • 0: The call will be non-modal, i.e. the caller program will continue the execution immediately after performing the call, without waiting that the called program finishes. 
  • 1: The call will be modal, i.e. the caller program will wait that the caller program finishes to return to the execution.

If we don’t specify any value, it is assumed 0 by default.

Description

If the Shell function successfully executes the named program, it returns 0 (zero). If the Shell function can't start the named program, it returns a number different from 0, depending on the error.
On Java generator we make an EXECUTE that should work on any environment provided that the file is executable.


Notes:

  • On Windows environment, this function use OLE to communicate with the application, so the application should support OLE automation.
  • On Web environment, the process is executed without GUI (graphical user interface) and with the same security permissions as the web application. 
  • On Java web applications, the process is executed in Tomcat's root directory.

In order to use this function the Master Model (design model), Model (working prototype/production model) or Object property “Functions” must be set with the value “Allows non-standard functions”.

It is possible to pass parameters when executing a program with the Shell function, for example:

&ret = shell('program.exe "C:\My Documents\filename.txt"') 

If the directory of the executable or of the parameters has white spaces, then it has to be delimited by " ", for example:

&ret = shell('"C:\Program Files\MyProgram.exe"   Parm1 Parm2')

Scope

Objects: Procedures, Transactions, Web Panels
Languages: .NET, Java, Visual FoxPro

Availability

As of Genexus 16 Upgrade 2 when you use this function, you must include the GXClasses.Win.dll file manually in your deploy. See SAC#44468

Security Tips

-If this function is used sanitizing external user's inputs is a must.







 

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.