In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

How to start another process from my app

Xailer English public forum
Responder
Gejza Horvath
Mensajes: 281
Registrado: Mar Ago 15, 2006 1:50 pm

How to start another process from my app

Mensaje por Gejza Horvath »

Hi Ignazio,
I would like to start another app from my app, waiting for finish and continue the work in
my app. I tried the Process Class, but no succes. The command line is here long enough:
"C:Program FilesVemaVemaStartVema.exe" /App=DBV /Idnfile=D:EKOSDATAAGIMuct.idn
/Role=Geza /Password=welle /DBVCommand="editor 15 zoznam"
cCommand := '"C:Program FilesVemaVemaStartVema.exe" '+ '/App=DBV ' + ;
'/Idnfile=' +cPath + 'uct.idn' + ;
' /Role=' + oIni:GetEntry("Vema","Uzivatel") + ;
' /Password=' + oIni:GetEntry("Vema","Heslo") + ;
' /DBVCommand="editor 15 zoznam" '
oProces := Tprocess():New()
oProces:cName := cCommand
oProces:lWait := .T.
oProces:Run()
The process doesn't starts. From the command line the application starts correctly with
this command.
If the cCommand := '"C:Program FilesVemaVemaStartVema.exe" ', the process starts. It
seems, the Process class can't handle the parameters, but I need them.
Gejza Horvath
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

How to start another process from my app

Mensaje por Stephan Hennekens »

Gejza,
are you sure the command is in ONE string, and not devided into several
strings? I guess ONE string is needed here.
Stephan
"Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
news:[email=46320824@ozsrv2.ozlan.local...]46320824@ozsrv2.ozlan.local...[/email]
> Hi Ignazio,
> I would like to start another app from my app, waiting for finish and
> continue the work in my app. I tried the Process Class, but no succes. The
> command line is here long enough:
>
> "C:Program FilesVemaVemaStartVema.exe" /App=DBV
> /Idnfile=D:EKOSDATAAGIMuct.idn /Role=Geza /Password=welle
> /DBVCommand="editor 15 zoznam"
>
> cCommand := '"C:Program FilesVemaVemaStartVema.exe" '+ '/App=DBV ' + ;
> '/Idnfile=' +cPath + 'uct.idn' + ;
> ' /Role=' + oIni:GetEntry("Vema","Uzivatel") + ;
> ' /Password=' + oIni:GetEntry("Vema","Heslo") + ;
> ' /DBVCommand="editor 15 zoznam" '
>
> oProces := Tprocess():New()
> oProces:cName := cCommand
> oProces:lWait := .T.
> oProces:Run()
>
> The process doesn't starts. From the command line the application starts
> correctly with this command.
> If the cCommand := '"C:Program FilesVemaVemaStartVema.exe" ', the
> process starts. It seems, the Process class can't handle the parameters,
> but I need them.
>
> Gejza Horvath
>
Gejza Horvath
Mensajes: 281
Registrado: Mar Ago 15, 2006 1:50 pm

How to start another process from my app

Mensaje por Gejza Horvath »

Yes,
I writed the command from my App into export.bat file. Running this batch file works fine.
Here is the modified code:
cCommand := '"C:Program FilesVemaVemaStartVema.exe" '+ '/App=DBV ' + ;
'/Idnfile=' +cPath + 'uct.idn' + ;
' /Role=' + oIni:GetEntry("Vema","Uzivatel") + ;
' /Password=' + oIni:GetEntry("Vema","Heslo") + ;
' /DBVCommand="editor 15 zoznam" '
nPointer := FCREATE(".export.bat")
FWRITE(nPointer,cCommand)
FCLOSE(nPointer)
oProces := Tprocess():New()
oProces:cName := '.export.bat'
oProces:lWait := .T.
oProces:Run()
The only problem I have is the batch file starts the Vema.exe process and terminates, and
I can't determine, when Vema.exe is finishing. oProces:lIsRunning returns .F. immediatly.
Gejza Horvath
"Stephan Hennekens" <stephan.hennekens@wur.nl> pí¹e v diskusním pøíspìvku
news:46322dcc$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
> Gejza,
>
> are you sure the command is in ONE string, and not devided into several strings? I guess
> ONE string is needed here.
>
> Stephan
>
> "Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
> news:[email=46320824@ozsrv2.ozlan.local...]46320824@ozsrv2.ozlan.local...[/email]
>> Hi Ignazio,
>> I would like to start another app from my app, waiting for finish and continue the work
>> in my app. I tried the Process Class, but no succes. The command line is here long
>> enough:
>>
>> "C:Program FilesVemaVemaStartVema.exe" /App=DBV /Idnfile=D:EKOSDATAAGIMuct.idn
>> /Role=Geza /Password=welle /DBVCommand="editor 15 zoznam"
>>
>> cCommand := '"C:Program FilesVemaVemaStartVema.exe" '+ '/App=DBV ' + ;
>> '/Idnfile=' +cPath + 'uct.idn' + ;
>> ' /Role=' + oIni:GetEntry("Vema","Uzivatel") + ;
>> ' /Password=' + oIni:GetEntry("Vema","Heslo") + ;
>> ' /DBVCommand="editor 15 zoznam" '
>>
>> oProces := Tprocess():New()
>> oProces:cName := cCommand
>> oProces:lWait := .T.
>> oProces:Run()
>>
>> The process doesn't starts. From the command line the application starts correctly with
>> this command.
>> If the cCommand := '"C:Program FilesVemaVemaStartVema.exe" ', the process starts.
>> It seems, the Process class can't handle the parameters, but I need them.
>>
>> Gejza Horvath
>>
>
>
>
Stephan Hennekens
Mensajes: 305
Registrado: Jue Nov 30, 2006 12:17 am

How to start another process from my app

Mensaje por Stephan Hennekens »

I tried something simple like
oProcess := TProcess():New()
oProcess:cName := "Notepad.exe test.txtl"
oProcess:Run()
This doesn't even start Notepad. Only when applying oProcess:cName :=
"Notepad.exe" Notepad pops up.
I am afraid Ignacio or Jose can help you out here.
Regards,
Stephan
"Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
news:[email=4632e626@ozsrv2.ozlan.local...]4632e626@ozsrv2.ozlan.local...[/email]
> Yes,
> I writed the command from my App into export.bat file. Running this batch
> file works fine. Here is the modified code:
>
> cCommand := '"C:Program FilesVemaVemaStartVema.exe" '+ '/App=DBV ' + ;
> '/Idnfile=' +cPath + 'uct.idn' + ;
> ' /Role=' + oIni:GetEntry("Vema","Uzivatel") + ;
> ' /Password=' + oIni:GetEntry("Vema","Heslo") + ;
> ' /DBVCommand="editor 15 zoznam" '
>
> nPointer := FCREATE(".export.bat")
> FWRITE(nPointer,cCommand)
> FCLOSE(nPointer)
>
> oProces := Tprocess():New()
> oProces:cName := '.export.bat'
> oProces:lWait := .T.
> oProces:Run()
>
> The only problem I have is the batch file starts the Vema.exe process and
> terminates, and I can't determine, when Vema.exe is finishing.
> oProces:lIsRunning returns .F. immediatly.
>
>
> Gejza Horvath
>
> "Stephan Hennekens" <stephan.hennekens@wur.nl> pí¹e v diskusním pøíspìvku
> news:46322dcc$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>> Gejza,
>>
>> are you sure the command is in ONE string, and not devided into several
>> strings? I guess ONE string is needed here.
>>
>> Stephan
>>
>> "Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
>> news:[email=46320824@ozsrv2.ozlan.local...]46320824@ozsrv2.ozlan.local...[/email]
>>> Hi Ignazio,
>>> I would like to start another app from my app, waiting for finish and
>>> continue the work in my app. I tried the Process Class, but no succes.
>>> The command line is here long enough:
>>>
>>> "C:Program FilesVemaVemaStartVema.exe" /App=DBV
>>> /Idnfile=D:EKOSDATAAGIMuct.idn /Role=Geza /Password=welle
>>> /DBVCommand="editor 15 zoznam"
>>>
>>> cCommand := '"C:Program FilesVemaVemaStartVema.exe" '+ '/App=DBV ' +
>>> ;
>>> '/Idnfile=' +cPath + 'uct.idn' + ;
>>> ' /Role=' + oIni:GetEntry("Vema","Uzivatel") + ;
>>> ' /Password=' + oIni:GetEntry("Vema","Heslo") + ;
>>> ' /DBVCommand="editor 15 zoznam" '
>>>
>>> oProces := Tprocess():New()
>>> oProces:cName := cCommand
>>> oProces:lWait := .T.
>>> oProces:Run()
>>>
>>> The process doesn't starts. From the command line the application starts
>>> correctly with this command.
>>> If the cCommand := '"C:Program FilesVemaVemaStartVema.exe" ', the
>>> process starts. It seems, the Process class can't handle the parameters,
>>> but I need them.
>>>
>>> Gejza Horvath
>>>
>>
>>
>>
>
>
notelo
Mensajes: 54
Registrado: Sab Abr 28, 2007 2:06 pm

How to start another process from my app

Mensaje por notelo »


Gejza,
you are right, there was a stupid bug I introduced in TProcess management
some time ago.
Add the attached OBJ to your project and test it again.
Regards,
José Lalí­n
--
Gejza Horvath
Mensajes: 281
Registrado: Mar Ago 15, 2006 1:50 pm

How to start another process from my app

Mensaje por Gejza Horvath »

Thanks José,
now it works fine, but I have another question. The code
.
.
IF oProces:Run()
MessageBox(Self,"Running export ....")
ELSE
MessageBox(Self,"Error during export.")
ENDIF
.
.
always traps in error Message, never into the "Running export ..." message. The process
starts correctly, but the oProces:Run() always returns .F.
Is the error in the Run() method code, or somwhere else?
Gejza Horvath
"José Lalín" <notelo@digo.com> pí¹e v diskusním pøíspìvku
news:46333909$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Gejza,
>
> you are right, there was a stupid bug I introduced in TProcess management
> some time ago.
>
> Add the attached OBJ to your project and test it again.
>
> Regards,
> José Lalín
>
notelo
Mensajes: 54
Registrado: Sab Abr 28, 2007 2:06 pm

How to start another process from my app

Mensaje por notelo »

Gejza,
> Thanks José,
> now it works fine, but I have another question. The code
Glad to hear that.
> always traps in error Message, never into the "Running export ..." message. The process
> starts correctly, but the oProces:Run() always returns .F.
>
> Is the error in the Run() method code, or somwhere else?
Are you using lWait member ? If yes you have to take care about it.
Check this:
oProcess:Run()
IF oProcess:IsRunning()
MessageBox( "Running export ..." )
ELSE
...
ENDIF
Let me know if it works.
Regards,
José Lalí­n
Gejza Horvath
Mensajes: 281
Registrado: Mar Ago 15, 2006 1:50 pm

How to start another process from my app

Mensaje por Gejza Horvath »

I have it! The app Vema.exe starts another process and terminates itself. This is the
reason, why oProces:IsRunning returns .F.
Changing the command line to start immediatly the second process solves the problem.
Thank you for your help
Gejza Horvath
"José Lalín" <notelo@digo.com> pí¹e v diskusním pøíspìvku
news:46334706$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
>
> Gejza,
>
>> Thanks José,
>> now it works fine, but I have another question. The code
>
> Glad to hear that.
>
>> always traps in error Message, never into the "Running export ..." message. The process
>> starts correctly, but the oProces:Run() always returns .F.
>>
>> Is the error in the Run() method code, or somwhere else?
>
> Are you using lWait member ? If yes you have to take care about it.
>
> Check this:
>
> oProcess:Run()
>
> IF oProcess:IsRunning()
> MessageBox( "Running export ..." )
> ELSE
> ...
> ENDIF
>
> Let me know if it works.
>
> Regards,
> José Lalín
>
notelo
Mensajes: 54
Registrado: Sab Abr 28, 2007 2:06 pm

How to start another process from my app

Mensaje por notelo »

Gejza,
> I have it! The app Vema.exe starts another process and terminates itself. This is the
> reason, why oProces:IsRunning returns .F.
> Changing the command line to start immediatly the second process solves the problem.
Good !
> Thank you for your help
You are welcome.
Regards,
José Lalí­n
Responder