1

I need to open external exe file, and in the same time to pass some arguments to it.

The documentation in Xojo Library suggest to use the Shell, but I have not seen the practical example how to do it.

Xojo Shell command Explanation:

Dim sh As New Shell

sh.Execute("Location to a file")

I have tried the following:

sh.Execute("Location to a file" + " " + myArgumentOne + " " + myArgumentTwo)

There is no error, just the *.exe is not being run.

If there is solution using FolderItem, I would gladly use it as well.

Amiga500
  • 5,874
  • 10
  • 64
  • 117
  • 1
    If the `Location to a file` might contain spaces then you need to enclose it with quotation marks before passing it to `Shell.Execute`. ([See here](http://docs.xojo.com/index.php/%22%22#Including_a_double_quote_inside_a_literal_string) for adding double quotes to string literals.) Otherwise, the shell will not be able to locate the executable. e.g. `sh.Execute("""Location to a file""" + " " + myArgumentOne + " " + myArgumentTwo)` – Andrew Lambert Sep 11 '14 at 20:43

2 Answers2

2

You may not need to use a shell. When you have the folderitem, use Launch to execute the program and pass parameters. For instance

  dim f as folderitem = GetFolderItem("C:\myprogram.exe", Folderitem.PathTypeShell)
  f.Launch("Parameter1, Parameter2")

See http://docs.xojo.com/index.php/FolderItem.Launch

Mitch Match
  • 339
  • 4
  • 14
1
sh.Execute F.ShellPath +"\program.exe " + parameters

F is a Folderitm pointing to the directory of the program and parameters is a string

Mex
  • 196
  • 4
  • 16