RunApp

Activates a UWP or Windows Store Application (Requires Windows 8.1/2012R2 or newer.)

Syntax:

RunApp (app-name, parameters [, flags ])

Parameters:

(s) app-name:  application name or AUMID.

(s) parameters:  application parameters. Can be an empty string.

(i) flags: [optional] a value indicating the content type of the application-name parameter :

Value

Meaning

0

(default) "app-name" is the application name.
 

1

"app-name" is the AUMID of the application.
 

Returns:

(i)  Process ID if the specified application is activated; 0 if the specified application is not activated.

 

This function activates a Universal Windows Platform (UWP) application or Windows Store application using either the application's name or the application's AUMID. The function returns the process ID of the running application. The returned process ID can be used as a parameter to other WIL functions. The target application is launched in the current sessions default context.

Note: This function returns an invalid parameter error when the app-name parameter is the name or ANUMID of a non UWP application.

"App-name" is the name of the application as assigned by the applications developer. It is often the root name of the application's executable file but it can be almost anything.

You can also use an Application User Model ID (AUMID) in the app-name parameter. The AUMID can either be defined by the system or the application itself. An application can potentially have more than one AUMID.

 Use the following script to identify the AUMIDs of all applications on the start menu of Windows 10 and newer systems.

Note: Since only UWP applications will start using the RunApp function, not all AUMIDs returned by the script can be use with this function.


Shell = CreateObject("Shell.Application") AppFolder = Shell.NameSpace("shell:Appsfolder") Apps = AppFolder.Items() Names = MapCreate() ForEach App In Apps Names[App.Name] = App.Path Next ; Alternatively, you could create a WIL dialog to display all Start Menu AUMIDs. Message("Notepad AUMID", Names["Notepad"])
Example:
  ; Start Notepad using the AUMID. You can use "Notepad" instead
  ProcId = RunApp("Microsoft.WindowsNotepad_8wekyb3d8bbwe!App" ,"", 1)
  
  ; Got a ProcID?
  Terminate( ProcId == 0, "Error", "Notepad did not start") 
  
  ; Pause until our Notepad instance closes
  AppWaitClose(ProcId, 2)
See Also:

AppExist, AppWaitClose, RunShell, ShellExecute, ShellExecuteWait, TerminateApp