Run external app or exe

I have a question that is bothering me, and I want to hear the different points of view in this forum.

Can Xojo run an EXE and pass parameters?

For example, running the calculator app. Assuming it can receive parameters.

Yes, easily. Use the Shell class
https://documentation.xojo.com/api/os/shell.html#shell-execute

1 Like

or FolderItem.Open
https://documentation.xojo.com/api/files/folderitem.html#folderitem-open

Shell uses FolderItem to select a file.

Not sure what you mean here.

' myApp is a FolderItem pointing to the app you want to open
Var sh As New Shell
sh.Execute("open -n " + myApp.ShellPath)

That only means that the example is using myApp as FolderItem but in fact is using the resulting ShellPath (that is a String).

In other words, you can replace myApp.ShellPath with the actual path typed by you like C:\Program Files\calc.exe instead of using myApp.ShellPath

Correct.
As you can see, FolderItem is not using the OPEN command. FolderItem cannot make a call to run an application (EXE, APP).

A few of the replies here are for macOS, not Windows. @Jose_Fernandez_del_Valle - can you confirm which OS you are talking about? (This thread was posted in the Targets / Windows channel, so I’m a little confused).

It is for Windows.

All the samples were from the XOJO manual. They show commands for MAC.

I’m sorry I don’t have Windows here to test, so I searched the forum for Windows specific shell posts. Maybe this one can help you?

I hope someone with Windows can help you in the next couple of days, if not I’ll try to install a Windows VM and create an example.

Yes, there are examples that are Mac specific. Just change them to what you will use using windows. Like, the command that you will use if you are using a prompt to execute the calc.exe on Windows (not using open and just pointing to the exe)

Edit: using shell should be similar to use the prompt on Windows (there are some differences)

Thanks Mike !!!
Thanks to everyone.

Here is the solution:

  1. Type the Windows-compatible command.
  2. Call PowerShell
  3. Run command
Var f As FolderItem
Var iShell As New Shell
Var cCommand As String = "start-process D:\Power_Automate\PAD.Console.Host.exe "+ EndOfLine

Print cCommand

f = FolderItem.DriveAt(1).Child("Power_Automate").Child("PAD.Console.Host.exe")

If f.Exists Then
  iShell.Execute("PowerShell")
  Print iShell.Result
  iShell.Execute(cCommand)
  Print iShell.Result
End If


Var Stop AS String = Input