ShellExecute in LUA

361 views
Skip to first unread message

fch...@gmail.com

unread,
Apr 7, 2008, 6:00:49 PM4/7/08
to scite-interest
Hi,

I would like to call exe files from lua.
There are 2 functions os.execute and io.popen that works fine but when
I use one of these functions, a console dos box is always displayed on
the screen.

Is there another way to shellexecute programs from LUA without
displaying this annoying console?

Thanks and best regards,
Fabio Chelly

KHMan

unread,
Apr 7, 2008, 10:10:18 PM4/7/08
to scite-i...@googlegroups.com
fch...@gmail.com wrote:
> I would like to call exe files from lua.
> There are 2 functions os.execute and io.popen that works fine but when
> I use one of these functions, a console dos box is always displayed on
> the screen.
>
> Is there another way to shellexecute programs from LUA without
> displaying this annoying console?

To my best of knowledge, os.execute is unchanged from the Lua
version. So, console output will cause a missing console window to
be created etc. Unfortunately, Win32 has two console call paths,
and dealing with redirecting both is something of a black art.

Try this: http://lua-users.org/wiki/SciteOther

Be warned that the above might still fail for executables using
direct console output such as UPX (I think). Do let the list know
about your experiences with scite_other.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

SteveD

unread,
Apr 8, 2008, 2:46:14 AM4/8/08
to scite-interest
Fortunately, you can link in extra functions as SciTE extension
DLLs. This is much more elegant than scite-other, which is
a hack I cooked up when there was no other way to do this.
This DLL wraps the ShellExec API, with a slightly different
parameter order.

http://groups.google.com/group/scite-interest/web/shellexec.zip

shellexec.exec(file,parameters,noshow,verb)

where noshow can be used to hide the window, and verb would
be something like 'open' or 'print'.

Here is how you would use it: copy shellexec.dll to the same
directory as your SciTE executable.

-- load the extension
require 'shellexec'

-- open a document
shellexec.exec('mydoc.doc')

-- print a document
shellexec.exec('mydoc.doc',nil,'print')

-- open Scite
shellexec.exe('SciTE','myfile.c')

-- execute a DOS command silently
shellexec.exec('cmd','/c dir > out.txt',true)

steve d.

On Apr 8, 4:10 am, KHMan <keinh...@gmail.com> wrote:

fch...@gmail.com

unread,
Apr 8, 2008, 4:31:53 AM4/8/08
to scite-interest
Thank you. That's exactly what I was looking for.

Best regards,
Fabio Chelly
Reply all
Reply to author
Forward
0 new messages