Question Regarding shell.Execute

I’m trying to launch a Windows app from inside my Xojo app. The Windows app is called RNR2_Import.exe.

If the Windows app is stored in the same folder as my Xojo app, all I need to do is execute this code.

  [code]       Dim sh As New Shell
         sh.Execute("RNR2_Import.exe")[/code]

But the Windows app I want to launch is stored in a parent fold above the Xojo app.

MyAppFolder
RNR2_Import.exe
RR2Folder
MyXojoApp (I want to run the sh.Execute from this folder and laugh RNR2_Import.exe from the folder above)

How do you write the code so that the sh.Execute code will run in the folder above you application folder?

I tried this code, but it does not work.

Dim f as folderitem = getfolderitem("").parent.child("RNR2_Import.exe") Dim sh As New Shell sh.Execute("f")

I also tried this code which also did not work:

[code]	dim f as folderitem = getfolderitem("").parent.child("RNR2_Import.exe")
           Dim sh As New Shell
			sh.execute "dir /x "+f.shellpath[/code]

I’m not sure how to do this.

I’m trying to launch a Windows app from inside my Xojo app. The Windows app is called RNR2_Import.exe.

If the Windows app is stored in the same folder as my Xojo app, all I need to do is execute this code.

 [code]        Dim sh As New Shell
         sh.Execute("RNR2_Import.exe")[/code]

But the Windows app is stored in a parent fold above the Xojo app.

MyAppFolder
________RNR2_Import.exe
________RR2Folder
-----------------MyXojoApp (This is where I want to launch the sh.Execute from to run RNR2_Import.exe from

How do you write the code so that the sh.Execute code will run in the folder above you application folder.

I tried this code, but it does not work.

[code]	Dim f as folderitem = getfolderitem("").parent.child("RNR2_Import.exe")
             Dim sh As New Shell
	 sh.Execute("f")[/code]

That did not work.

I also tried to run this code and it did not work either

     [code]        Dim f as folderitem = getfolderitem("").parent.child("RNR2_Import.exe")
             Dim sh As New Shell
	 sh.execute "dir /x "+f.shellpath[/code]

Not sure how to do this.

To get the Native Path to your Apps Folder, you can access the App.ExecutableFile Property.

Dim f as folderitem =  App.ExecutableFile.Parent.child("RNR2_Import.exe")

BTW: If you just need to launch another executable you can simply do a FolderItem.Launch :wink:

f.Launch

Hi Sascha,

Thank you for your response. My app is not stored in the Applications folder. The app I want to launch the shell.execute is stored in a subfolder in a different folder of the hard drive…

The sh.Execute code to launch RNR2_Import.exe would be run from the MyApp.exe application.

So I am not sure how to write the code so that it executes the RNR2_Import.exe application.

I always end up writing a batch file and executing that. First change to correct drive, then CD to correct folder, then the executable.
Or create batch file in your program’s folder ‘CD …’ to bump up one level, then the exe name on next line. You might manage it on one command line directly via shellexecute something like 'CD … & RNR2_Import.exe . ( Sorry I don’t have time to test right now ).

Okay Sascha,

The f.Launch did it! Here was the full code.

dim f as folderitem = getfolderitem("").parent.child("RNR2_Import.exe") f.Launch

You don’t even need the sh.Execute.

Thanks so much Sascha for your help. I really appreciate it.

And thank you Peter for your post as well.