Run external app from within Harbour app

182 views
Skip to first unread message

Tim J

unread,
Jan 19, 2023, 8:27:49 AM1/19/23
to Harbour Users
I want to run an external app from within a Harbour app.
I do not want it to change focus to that external app, 
But I want that app to finish before the main Harbour app continues.

is that possible?

Thanks

Lautaro Moreira

unread,
Jan 19, 2023, 8:32:15 AM1/19/23
to harbou...@googlegroups.com, Lautaro Moreira

Hello Tim,

Try with :

   nResultado:=hb_processrun(cComando ,,@csalida,@cerror,.T.)

Best regards,

Lautaro Moreira

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/b2a9e631-cd0f-4ec1-b1f5-df3105904d6cn%40googlegroups.com.

Mario H. Sabado

unread,
Jan 19, 2023, 8:38:15 AM1/19/23
to 'elch' via Harbour Users
Hi Tim,

Try to search wapi_ShellExecuteWait() if the external app takes time to complete to avoid the "Not Responding" message.

Regards,
Mario

--

Bernard Mouille

unread,
Jan 19, 2023, 11:03:43 AM1/19/23
to Harbour Users
Hello Tim,
With Windows, I use the code below my signature.
Regards,
Bernard.

/*
   bh_Run.ch
   Exécuter un programme avec options.

   Plante si on ne passe pas la bonne commande.
   Exemple Dos : 'cmd /K <Command1> &<Commande2> ... &<CommandN> &exit'

   #include "bh_Run.ch" // Exécuter un programme avec options.

   Dernière modification : 2022-10-28
   <web>http://bernard.mouille.free.fr/Harbour/bh_Run.txt</web>
*/

#ifndef _bh_Run_ch_
#define _bh_Run_ch_

procedure bh_Run( cCommand, nDisplay, lStop )

   if lStop == nil
      lStop := .T.
   endif
   if nDisplay == nil
      nDisplay := 1
   endif

   win_oleCreateObject( "WScript.Shell" ):Run( cCommand, nDisplay, lStop )

   return

#endif // _bh_Run_ch_

/*
// Test.prg
// Test du module bh_Run.ch.

#include "bh_ErrorSysCons.ch" // Gestion de l'affichage des erreurs de programme dans Harbour.
#include "bh_Run.ch"          // Exécuter un programme avec options.

procedure Main

   // ANSI ( Windows ) en français.
   request HB_LANG_FR
   request HB_CODEPAGE_FRWIN
   hb_cdpSelect( 'FRWIN' )
   hb_langSelect( 'FR' )

   // Taille de la console.
   setmode( 43, 80 )
   setcolor( "GR+/B" )
   @ 0, 0, maxrow(), maxcol() box space( 9 )
   setcolor( "W/B" )

   bh_Run( "cmd /K dir *.* & pause &exit", 1, .T. )
   wait

   bh_Run( "Notepad.exe", 1, .T. )
   wait

   return
*/

/*
# Test.hbp : Instructions de compilation Harbour.

# Nom de l'exe crée.
-oTest

# Ne crée pas l'exe en cas de Warning.
-w3
-es2

# Ajout de chemin(s) pour include ( fichiers Harbour .h et .ch ).
-iC:\BhPrg\_Lib\bh

# Programme(s) à compiler.
Test.prg

# Librairies : respecter l'ordre.
-lhbwin
*/

Ricardo Sassy

unread,
Jan 19, 2023, 3:00:51 PM1/19/23
to harbou...@googlegroups.com

Hi Tim

Try this:

 

cOutErr1    := ''

cOutErr2    := ''

cExternalApp := ‘notepad.exe’

nErrorLevel := HB_PROCESSRUN(cExternalApp,,@cOutErr1,@cOutErr2,.T.)         // .T. DOES NOT CONSOLE DISPLAY (SILENT MODE)

 

Regards…

Ricardo Sassy

 

 

 

--

Tim J

unread,
Jan 19, 2023, 3:51:08 PM1/19/23
to Harbour Users
Thank you very much everyone!

Bernard Mouille

unread,
Jan 19, 2023, 5:07:27 PM1/19/23
to Harbour Users
Hello Ricardo,

Thanks for the way, I have found a notice :

Regards,
Bernard.

r raj

unread,
Jan 20, 2023, 2:20:30 AM1/20/23
to Harbour Users
wapi_ShellExecute( 0, "Open", "notepad.exe", "DDS.TXT", "d:\" )

comple with hbwin.hbc

it works

Rajiniganth R

fdaniele

unread,
Jan 22, 2023, 2:42:06 AM1/22/23
to Harbour Users
i do this

   comando := 'start /wait copia_csv.bat  ' + cImportDir
   RUN ( comando )

Bernard Mouille

unread,
Jan 22, 2023, 10:45:40 AM1/22/23
to Harbour Users
Hello,

Is exists in Harbour a function like HB_PROCESSRUN() with a timeout to quit the function ?

Regards,

Bernard.
Reply all
Reply to author
Forward
0 new messages