Shiny Language Reference

Language Reference > Basic Language


shellexecute

bool shellexecute(string Target, string Params, string WorkingDir, int Style);

Synonyms:

bool run(string Target, string Params, string WorkingDir, int Style);
 

Executes the specified file or resource using Windows Explorer

The SHELLEXECUTE statement launches the specified file or resource with the specified parameters in the specified working directory. Because this statement uses Windows Explorer to launch the target it is possible to specify any executable or type that Explorer understands. For example, specifying a web address in the Target parameter will cause Explorer to load the HTTP handler, causing Internet Explorer to start and access the specified webpage. This is true for any resource understood by Explorer - if you can type the Target into the Start - Run dialog, you can use it in this statement.

 

Parameters

Target

The resource or executable to launch

Params

Any parameters that should be passed to the Target when it is launched

WorkingDir

If the Target must be run from a specific location, specify the working directory here

Style

An integer representing the style of window to open, if possible. The following definitions are already defined in SSEdit:

SW_HIDE 0
SW_NORMAL 1
SW_SHOWMINIMIZED 2
SW_SHOWMAXIMIZED 3
SW_SHOWNOACTIVATE 4
SW_SHOW 5
SW_MINIMIZE 6
SW_SHOWMINNOACTIVE 7
SW_SHOWNA 8
SW_RESTORE 9
SW_SHOWDEFAULT 10
SW_FORCEMINIMIZE 11

 

 

Return Value

True if the execution succeeded, otherwise False

 

Example Code

// Open MyProg.exe in the path, using C:\ as the working directory
shellexecute("MyProg.exe", "", "C:\\", 1);

// Open MyProg and pass it "-widget: blue" as a parameter
shellexecute("MyProg.exe", "-widget: blue", "C:\\", SW_NORMAL);

// Open www.mywebsite.com in a maximized window
shellexecute("http://www.mywebsite.com", "", "", SW_SHOWMAXIMIZED);