running external processes - executando processos externos

108 views
Skip to first unread message

Ronaldo Geniais

unread,
Feb 5, 2026, 6:42:20 PM (13 days ago) Feb 5
to Harbour Users
I have an app that runs a PowerShell cmd,
I create a variable containing the execution string and
run it with
hb_processRun(cCmd)
it works fine, but it opens the PowerShell window and closes,
I tried several ways to hide the PowerShell window but
it doesn't work.
ChatGPT says to replace HB_PROCESSRUN() with
HB_WINEXEC() or WNEXEC(), but I couldn't find that,
does anyone have a tip for this?



Tenho um app que executa um cmp powershell,
eu crio uma variavel contendo a string de execucao e
executo com 
hb_processRun( cCmd )
funciona bem,  porem abre a janela do powershell e fecha,
eu tentei de varias formas ocultar a janela do powershell mas
nao funciona.
O  ChatGPD  diz  para trocar HB_PROCESSRUN() por
HB_WINEXEC()  OU WNEXEC()  ,  mas nao encontrei isso,
alguem tem uma dica para isso ?

Maurizio la Cecilia

unread,
Feb 6, 2026, 5:03:25 AM (13 days ago) Feb 6
to Harbour User Group
Hi,
did you try with wapi_ShellExecute()?
It's in hbwin library. 

Best regards 
--
Maurizio 

--
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 visit https://groups.google.com/d/msgid/harbour-users/23698937-b727-4d9c-b278-b82038bbaa80n%40googlegroups.com.

Ronaldo Geniais

unread,
Feb 6, 2026, 8:29:21 AM (13 days ago) Feb 6
to Harbour Users
Thank you for the help,
I adjusted the program and switched to wapi_ShellExecute(cCmd)
It seems that it doesn't understand PowerShell execution, besides opening the file explorer folder over my application.
My command string to run PowerShell generates a file for me to read the output, this works with hb_processRun(ccmd), but as I said, it flashes on the screen showing PowerShell and then closes quickly (inconvenient) but functional. With wapi_ShellExecute() it doesn't work.

bernardm...@gmail.com

unread,
Feb 6, 2026, 11:23:29 AM (12 days ago) Feb 6
to Harbour Users
Maybe you can try :

/*
   Exécuter un programme avec options.

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

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


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


Reply all
Reply to author
Forward
0 new messages