Page 1 of 1
shellexec or winexec
Posted: Fri Dec 06, 2019 6:00 am
by Otto
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
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 9:20 am
by Otto
Hello,
as a workaround I tried with a bat-file.
cd\
cd xwinhotel
call xwinhotel.exe
This is working.
Best regards
Otto
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 9:49 am
by Natter
Is that what you mean ?
cPt:=CurDrive()+':\'+CurDir()
SHELLEXECUTE( 0, 0, cPt+"\"+MyFile, 0, 0, 1)
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 11:32 am
by MGA
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
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 11:40 am
by MaxP
To run a second program in the same directory
Code: Select all | Expand
#include "FiveWin.ch"
FUNCTION Main()
LOCAL cPathProgr := cFilePath( GetModuleFileName( GetInstance() ) )
WinExec( cPathProgr + "PROGR2.EXE" )
RETURN NIL
Re: shellexec or winexec
Posted: Fri Dec 06, 2019 6:35 pm
by Otto
Hello,
thank you all for your help.
I will test all the solutions on the weekend.
Best regards
Otto