Página 1 de 1

How to start another process from my app

Publicado: Vie Abr 27, 2007 4:25 pm
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

How to start another process from my app

Publicado: Vie Abr 27, 2007 7:07 pm
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
>

How to start another process from my app

Publicado: Sab Abr 28, 2007 8:12 am
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
>>
>
>
>

How to start another process from my app

Publicado: Sab Abr 28, 2007 1:12 pm
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
>>>
>>
>>
>>
>
>

How to start another process from my app

Publicado: Sab Abr 28, 2007 2:06 pm
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
--

How to start another process from my app

Publicado: Sab Abr 28, 2007 2:44 pm
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
>

How to start another process from my app

Publicado: Sab Abr 28, 2007 3:06 pm
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

How to start another process from my app

Publicado: Dom Abr 29, 2007 8:42 am
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
>

How to start another process from my app

Publicado: Dom Abr 29, 2007 1:01 pm
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