Shell Execute How to ?

Hello all,

I am trying to execute a command from within my app using shell.execute.

  Dim sh As new Shell
  sh.Mode=0
 
  Dim s As string = Path + "upnpc-static.exe -a " + IP + " " + k_sp + " " + sPrt + " "+ k_sp + " " + tPrt + " "  + k_sp + " " +Protocol
  sh.Execute(s)

I have tried to set the path at least 3 different ways, and each time it fails.
Path = “C:\Axcys%Embedded\Axcys%Embedded%Engine%Service\Resources”
Path = “C:\Axcys Embedded\Axcys Embedded Engine Service\Resources”
Path = “C:\Axcys Embedded\Axcys Embedded Engine Service\Resources”

Without the % it says cannot find path c:\Axcys, the closest I have gotten is the example above with the % sign, but then it says the system cannot find the path specified.

The whole path presented is:
C:\Axcys%Embedded\Axcys%Embedded%Engine%Service\Resources\upnpc-static.exe -a 192.168.0.2 32123 32123 TCP

Can anyone give some suggestions how to handle this??? This is a Win7 platform BTW.

Thank you,
Tim

The shell command line requres quotes around the path if it contains spaces. In Xojo, you can insert a quote by using 2 ("") or with chr(34).

You need the final path to be

“C:\Axcys Embedded\Axcys Embedded Engine Service\Resources\upnpc-static.exe” -a 192.168.0.2 32123 32123 TCP

so your code should be

Dim s As string = “”"" + Path + “upnpc-static.exe -a”" " + IP + " " + k_sp + " " + sPrt + " "+ k_sp + " " + tPrt + " " + k_sp + " " +Protocol

Thanks Tim,
I wasted a bunch of time on that… and frustration too.

Much appreciated -
Tim

Well,
That did not work… completely.
As presented (thank you again) Shell returns this:

‘“C:\Axcys Embedded\Axcys Embedded Engine Service\Resources\upnpc-static.exe -a”’ is not recognized as an internal or external command, operable program or batch file.

If this is dissected, remarking everything from the right of the .exe, it will execute, but the executable will complain of missing options/commands. So while progress, not complete. I did also try to surround the options/commands -a etc. with a single quote, but that brought me back to it only reading the part c:\axcys as the complete path.

Any other ideas?

Thank you again!
Tim

Sorry. Misplaced quote. It goes after .exe, not after -a.

Dim s As string = “”"" + Path + “upnpc-static.exe”" -a " + IP + " " + k_sp + " " + sPrt + " "+ k_sp + " " + tPrt + " " + k_sp + " " +Protocol

Thank you! I keep trying different combinations and nothing works - but your change above did!
Thank you so much!
Tim

Hi Tim!
can you help me on this?

I need to execute a curl.exe, located at the same folder, but always get error 1. Here is my code:

Dim s As New Shell
Dim cmd As String
dim f as folderItem

f = getFolderItem(“curl.exe”)

cmd = f.nativePath + " -G www.google.com "

s.Execute(cmd)

If s.ErrorCode=0 Then
TextField1.Text = s.Result
Else
TextField1.Text = "Error " + Str(s.ErrorCode)
End If

Found!!!
.shellPath

Thanks

Julio,

Just read your post(s) - glad you found it!
TIm