PDA

View Full Version : Stuck on win.ShellExecuteEx



Mastiff
December 25th, 2011, 10:23 AM
I'm trying to run Foobar with a parameter, but I can't get it to work. This is the code:


local Stasjon = pld2
local Radiosone = pld3
local Nettradiostring1 = "C:\\Program files (x86)\\Foobar\\Sone "
local Nettradiostring2 = Radiosone
local Nettradiostring3 = '\\foobar2000.exe'
Nettradiostasjon = Stasjon
Nettradioprogram = (Nettradiostring1 .. Nettradiostring2 .. Nettradiostring3)

print(Nettradioprogram,Nettradiostasjon)

win.ShellExecuteEx (Nettradiostring, nil,nil,nil)

That gives me this printout when run:


C:\Program files (x86)\Foobar\Sone 5\foobar2000.exe http://lyd.nrk.no/nrk_radio_p1_sorlandet_mp3_h

And that should be all right. Except that it doesn't work at all. I get no error messages, but the program isn't run. I figured it was because of the space in the program path, so I added a few quotation marks, and I got this:


"C:\Program files (x86)\Foobar\Sone 5\foobar2000.exe" http://lyd.nrk.no/nrk_radio_p1_sorlandet_mp3_h

And that doesn't work either. Can anybody please tell me what I'm doing wrong here? I've spent a couple of hours of Christmas day scratching my head, and I was shaved before I started, so now I'm shining!

Tieske8
December 26th, 2011, 02:34 AM
Shouldn't you be executing "netradioprogram" instead of "netradiostring"? Netradiostring will be nil in the example code given.

Mastiff
December 26th, 2011, 02:39 AM
Sorry, my mistake. There was a line missing from the script in the post:



local Stasjon = pld2
local Radiosone = pld3
local Nettradiostring1 = "C:\\Program files (x86)\\Foobar\\Sone "
local Nettradiostring2 = Radiosone
local Nettradiostring3 = '\\foobar2000.exe'
Nettradiostasjon = Stasjon
Nettradioprogram = (Nettradiostring1 .. Nettradiostring2 .. Nettradiostring3)
Nettradiostring = (Nettradioprogram .. Stasjon)

print(Nettradioprogram,Nettradiostasjon)

win.ShellExecuteEx (Nettradiostring, nil,nil,nil)

Tieske8
December 26th, 2011, 04:04 AM
Do not concatenate the command and the arguments/parameters. The first argument to ShellExecuteEx is the fullpath to the executable, and the second parameter are the command line options.

This works;

local filename = '"C:\\Program Files\\Internet Explorer\\iexplore.exe"'
local param = 'http://www.promixis.com/'
win.ShellExecuteEx(filename, param, nil, nil)

Mastiff
December 26th, 2011, 04:14 AM
Thanks! That did it. :) Another thing: Isn't it possible to run the program hidden, like when I use the OS Execute file action? I thought it should work with the switch win.SW_HIDE instead of the final nil, but it didn't.

Tieske8
December 26th, 2011, 05:29 AM
Haven't tried that, but as a workaround you might try to create a shortcut with The right properties set and execute that one.

Mastiff
December 26th, 2011, 07:27 AM
Thanks, but as far as I know you can't do that in Windows. Hidden is when the program only surfaces on Task manager and not in the GUI. I can use a wait in the script and then a hide window function, but I'd like to start it already hidden, of possible.