FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour shellexec or winexec
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
shellexec or winexec
Posted: Fri Dec 06, 2019 06:00 AM

Hello,
I would need an example of how to use shellexec or winexec to run a program in the program's directory.

Best regards
Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 09:20 AM

Hello,
as a workaround I tried with a bat-file.

cd\
cd xwinhotel
call xwinhotel.exe

This is working.
Best regards
Otto

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 09:49 AM

Is that what you mean ?

cPt:=CurDrive()+':\'+CurDir()
SHELLEXECUTE( 0, 0, cPt+"\"+MyFile, 0, 0, 1)

Posts: 1286
Joined: Mon Feb 25, 2008 02:54 PM
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 11:32 AM

function MyRun( cComando, nStyle, lWait, lShowResult )

local oShell, nRetorno

IF valtype( nStyle ) != "N"
nStyle := 0
ENDIF

IF ValType( lWait ) != "L"
lWait := .T.
ENDIF

IF ValType( lShowResult ) != "L"
lShowResult := .F.
ENDIF

oShell := CreateObject( "WScript.Shell" )

IF !GetEnv( "OS" ) == "Windows_NT"
cComando += "start " + cComando
ENDIF

TRY
nRetorno := oShell:Run( "%comspec% /c " + cComando, nStyle, lWait )
CATCH
MsgStop("ERRO NO ENVIO DO COMANDO!", "MYRUN")
END

IF lShowResult .and. nRetorno > 0 .and. nRetorno <= 32
MsgInfo( "Erro Win_Run(): " + ltrim( Str( nRetorno ) ), "Win_Run - Error" )
ENDIF

oShell := NIL

Return nRetorno = 0

ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
Posts: 99
Joined: Thu Jul 12, 2007 02:02 PM
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 11:40 AM
To run a second program in the same directory

Code (fw): Select all Collapse
#include "FiveWin.ch"


FUNCTION Main()
        LOCAL   cPathProgr := cFilePath( GetModuleFileName( GetInstance() ) )
        
        WinExec( cPathProgr + "PROGR2.EXE" )
RETURN NIL
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 06:35 PM

Hello,
thank you all for your help.
I will test all the solutions on the weekend.
Best regards
Otto

Continue the discussion