Update cookies preferences
Promotic

ShellExecute - method of the Pm object

Description:
Launching or printing the file or the registered document.
Syntax:
Long ShellExecute(String sOperation, String sFile, String sParameters, String sFolder, Variant vOptions, [String sRequestId], [Function onComplete])
Parameters:
sOperation(String) Type of the operation with the file. If the parameter is empty string, then the "open" value is set.
"open" - The file has to be opened along with the associated application
"print" - The file has to be printed
"runas" - The same as "open", but with higher permissions. Caution! Windows UAC is invoked (darkening the screen and prompting you to confirm the higher permissions).
sFile(String) The file name with the path.
If a full path is not entered, then it is completed relative to the application folder.
It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files or folders.
sParameters(String) Parameters that have to be passed to the application associated to the running file
sFolder(String) Path to the working folder of the application.
It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files or folders.
vOptions(Variant) Additional parameters
KeyVal - Additional parameters entered as a string. Entries are in the KeyVal format, for example "state:hidden;timeout:10;"
state - Specifies the application display mode.
normal (default) - normal active
max - maximized active
min - minimized active
hidden - hidden
normal_na - normal not active
min_na - minimized not active
timeout - Specifies the maximum time for the operation in seconds. Default is -1, meaning unlimited timeout.
If the operation is not completed within the specified time, then the onComplete(ev) function is called, where the return value (the ev.Value parameter) will be undefined (invalid).
Number - The old way of specifying the display mode of the application using a number:
0 - hidden
1 - normal active
2 - minimized active
3 - maximized active
4 - normal not active
6 - minimized not active
sRequestId[optional] (String) Identifier of registered event function.
- Prevents duplicate registering of the same function.
- May contain any characters (this is not a system name).
- Must not be an empty string.
onComplete[optional] (Function) The parameter onComplete contains a function that will be called for asynchronous handover of the result. The function must be in syntax: function onComplete(ev) {};
where the parameter ev.Value contains the returned value (result) of the asynchronous calling.
The result is the value returned by the running application on its termination.
If no error occurred, then this value is usually 0.
If the application was not terminated within the timeout specified by the timeout parameter, then the return value is undefined.
Return value:
If the operation passed successfully, then the method returns the 0 value, otherwise it returns the error number:
1 - out of memory
3 - the specified file has not been found
4 - the specified path has not been found
Note:
The method serves to running or printing a *.exe file or the file that is registered in Windows OS along with the associated application.

This method is not functional in Web panels. This method is asynchronous.
See also:
- Pm.CreateProcess (method)
Example1:
Print the text file "experiment.htm" in the InternetExplorer:
JavaScriptVBScriptSelect and copy to clipboard

Pm.ShellExecute("print", "#app:experiment.htm", "", "#app:", 0);
Example2:
Displays the Windows system window for the network printer "\\SERVER\PRINTER1:"
JavaScriptVBScriptSelect and copy to clipboard

Pm.ShellExecute("", "\\\\SERVER\\PRINTER1", "", "", 0);
Example3:
Launching the PowerPoint application.
JavaScriptVBScriptSelect and copy to clipboard

Pm.ShellExecute("open", "C:\\PowerPoint\\presentation.pps", "", "C:\\PowerPoint\\", 1);
Example4:
Opening a local PDF file in the Edge Web browser.
JavaScriptVBScriptSelect and copy to clipboard

var sPathBrowser = "c:/Program Files (x86)/Microsoft/Edge/Application/";
Pm.ShellExecute("open", sPathBrowser + "msedge.exe", "c:/download/filename.pdf", sPathBrowser, 3);
To display the desired web page in the browser, it is preferable to use: CreateProcess or Opening the viewer of Web pages (/#glob/webbrowser)
Example5:
Sending a file to the FTP server with confirmation of the completed transfer.
JavaScriptSelect and copy to clipboard

var sUser = "ftpname:ftppassword";
var sFtpFile = "ftp://ftpservername.com/dir/filename.pdf";
var sLocalFile = "c:/Test/filename.pdf";
var sSend = ' -T "' + sLocalFile + '" -u "' + sUser + '" --url "' + sFtpFile + '"';

Pm.ShellExecute("open", "c:/Windows/System32/curl.exe", sSend, "", "state:hidden;", pMe.GetPathName(), onComplete);

function onComplete(ev)
{
if (!ev.Value)
{
Pm.Debug("FTP transfer is OK");
}
}

History:
Pm9.00.30: New option "runas" to launch with higher permissions.
Pm9.00.29: New sRequestId parameter and new onComplete parameter, allowing asynchronous retrieval of the result of the operation.
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- LN2
- PI
- Pow
- ShellExecute
 
 
- Sin
- Tan
© MICROSYS, spol. s r.o.