lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2010/4/15 Enrico Colombini <erix@erix.it>:
> Attila wrote:
>>
>> I want to execute a command to get the label of a hard disk by VOL C:. The
>> only problem that os.execute() flashes the black shell window, and I don't
>> like this. I guess it's possible without it, but don't know, how.
>
> If you can tolerate an icon flashing in the taskbar (and you started the
> program from a console) this could do:
>
>  local cmd = 'dir'
>  os.execute('start /min cmd /c ' .. cmd)

This won't help, you will get to console windows: one for the start
command and another one (minimized) for "started" cmd.  There is no
way to get rid of the flashing window effect other than to pass the
appropriate flags to CreateProcess API (either DETACHED_PROCESS or
CREATE_NO_WINDOW in creation flags or SW_HIDE in startup info).

Anyway, the OP should use io.popen instead of os.execute to get the output.

Cheers,

Tomek