hb_Run() / hb_ProcessRun() command prompt window

1,827 views
Skip to first unread message

Gmail

unread,
Jun 20, 2013, 10:06:03 AM6/20/13
to harbou...@googlegroups.com
Hello,
 
    Sorry for asking it but I really didn’t get...
    I am trying to make a simple program that does execute a simple task but I do not it to open the command prompt window to do that.
    With hb_Run() it does open.
    With hb_ProcessRun() it does not open but does not do the task.
    Follows a simple example that I build with hbmk2 tst -gui:
 
 
ANNOUNCE HB_GTSYS
REQUEST HB_GT_NUL_DEFAULT
 
PROCEDURE Main()
 
//  hb_Run( 'start .' )
    hb_ProcessRun( 'start .' )
RETURN
 
 
    What am I missing?
    Thanks for any help.
    Regards,
 
Qatan
 
 

Sami Laham

unread,
Jun 20, 2013, 5:01:17 PM6/20/13
to harbou...@googlegroups.com
Hi Quatan, i don´t know if i understood what do you want do but take a look at the link below 


may be it will help you 

Regards 

Sami  

Przemyslaw Czerpak

unread,
Jun 20, 2013, 8:30:27 PM6/20/13
to harbou...@googlegroups.com
On Thu, 20 Jun 2013, Gmail wrote:

Hi,
'start' is not program but internal windows shell command.
HB_RUN() executs command indirectly using default shell/comspec
unlike HB_PROCESSRUN() which uses direct code.
If you want to execute internal shell commands using HB_PROCESS*()
functions you can call them by:
hb_processRun( 'cmd /c start .' )
or more generally:
cCommand := "start ."
hb_processRun( getEnv( "COMSPEC" ) + " /c " + cCommand )

best regards,
Przemek

Gmail

unread,
Jun 21, 2013, 3:23:58 AM6/21/13
to harbou...@googlegroups.com
Hello Sami,
 
    Thanks for your willingness to help.
    I think the link will not help me although is a good place to start for sure.
    Regards,
 
Qatan
 

Gmail

unread,
Jun 21, 2013, 3:41:35 AM6/21/13
to harbou...@googlegroups.com
Hello Przemek,

Thanks for helping. It makes clear to me how to use hb_ProcessRun().
But... it still opens the mentioned command prompt window (although for
a fraction of a second).
The only way to avoid that is doing as the code below. Please correct me
if I am wrong...
The problem with that is that it is a Windows only solution.
Regards,

Qatan

------8<-----
// Compile with hbmk2 tst -gui -lhbwin
// For this example you need to have

ANNOUNCE HB_GTSYS
REQUEST HB_GT_NUL_DEFAULT

PROCEDURE Main()

LOCAL cCommand := 'start tst.txt'
LOCAL cFile := 'tst.txt'

// hb_Run( 'start .' )
// hb_processRun( getEnv( "COMSPEC" ) + " /c " + cCommand )
MyRun( '"START "" /MIN "' + cFile + '"' )

RETURN


FUNCTION MyRun( cCommand, lFlag )

LOCAL oShell, nErrorlevel

hb_Default( @lFlag, .F. )

oShell := WIN_OleCreateObject( "WScript.Shell" )
nErrorlevel := oShell:RUN( GETENV( "COMSPEC" ) + " /c " + cCommand, 0,
lFlag )
// nErrorlevel := oShell:RUN( "%COMSPEC% /c " + cCommand, 0, lFlag ) //
Optional way
oShell := NIL

RETURN IF( nErrorlevel = 0, .T., .F. )

------>8------

SD

unread,
Jun 21, 2013, 5:43:14 AM6/21/13
to harbou...@googlegroups.com
In case someone here is looking for the solution to just simply execute/open any external file, the following code works under windows (7 or xp) and Hb3.0 to open an excel file:

cFilename:="tst.xls"
hb_run(cFilename) // opens the file but cmd black box is invoked initially.....

Here no cmd black box appears, only file gets opened:
wapi_ShellExecute( 0, 'open', cFilename, , 0, 0 )
Reply all
Reply to author
Forward
0 new messages