Question about WinExec()

Question about WinExec()

Postby driessen » Mon Apr 19, 2021 2:45 pm

Hello,

Why isn't this code working?
Code: Select all  Expand view
WinExec("TASKKILL.EXE /IM OUTLOOK.EXE /F",0)
When I try this command line in the command prompt, it is working just fine.

Someone any idea?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Question about WinExec()

Postby karinha » Mon Apr 19, 2021 3:04 pm

Maybe:

Code: Select all  Expand view

WinExec("TASKKILL /F /s terminal /u password /im OUTLOOK.EXE",0)
 


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7804
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Question about WinExec()

Postby hua » Tue Apr 20, 2021 1:38 am

Michel,
Maybe can try experimenting with ShellExecute()
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Question about WinExec()

Postby driessen » Tue Apr 20, 2021 7:36 am

Thanks for your suggestion, but ShellExecute() doesn't do the job either.

So I developed a solution by going arround the problem :
Code: Select all  Expand view
IF FILE(nProg1 + "KILLOUT.BAT") ; DELETE FILE(nProg1 + "KILLOUT.BAT") ; ENDIF
aOutFile := FCREATE(nProg1 + "KILLOUT.BAT")
FWRITE(aOutFile,"TASKKILL.EXE /F /IM OUTLOOK.EXE")
FCLOSE(aOutFile)
WinExec(nProg1 + "KILLOUT.BAT",0)
SYSWAIT(1)
IF FILE(nProg1 + "KILLOUT.BAT") ; DELETE FILE(nProg1 + "KILLOUT.BAT") ; ENDIF
And guess what? It works this way.

Thank you.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Question about WinExec()

Postby Antonio Linares » Tue Apr 20, 2021 8:20 am

very good!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Question about WinExec()

Postby Enrico Maria Giordano » Tue Apr 20, 2021 9:03 am

driessen wrote:Hello,

Why isn't this code working?
Code: Select all  Expand view
WinExec("TASKKILL.EXE /IM OUTLOOK.EXE /F",0)
When I try this command line in the command prompt, it is working just fine.

Someone any idea?

Thanks.


I tried your sample as is and it worked fine.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Question about WinExec()

Postby Euclides » Tue Apr 20, 2021 12:54 pm

Hi to all.

WinExec("TASKKILL.EXE /IM NOTEPAD.EXE /F",0)
did not work im my computer (W 8.1)
but...

WinExec("CMD /C TASKKILL.EXE /IM NOTEPAD.EXE /F",0)
did the job.
Regards, Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Re: Question about WinExec()

Postby driessen » Tue Apr 20, 2021 4:03 pm

Thank you very much for your suggestion.
I'll try it out tomorrow.

After edit : Thank you so much. It works fine now.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Question about WinExec()

Postby Otto » Wed Apr 21, 2021 5:52 am

Hello Euclides,

May I ask for your help.
Do you think that I could replace this function with a Winexec().

Code: Select all  Expand view

function runIndxprg( nkdnr )
    local cText := ""
   
    cText += "cd\" + CRLF
    cText += "
cd C:\Windows\System32" + CRLF
    cText += "
REM window-position=y col,x row" + CRLF  
    cText += "
start chrome --new-window --app=https://test.com.space/formular/index.prg?recnr=" + ALLTRIM(STR( nkdnr )) + "--window-position=600,300  --window-size=1500,730"

    memowrit("c:\xwinhotel\formular.bat", cText )
   
    waitrun( "c:\xwinhotel\formular.bat", 0 )

return nil
   
 


Sincerely
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6322
Joined: Fri Oct 07, 2005 7:07 pm

Re: Question about WinExec()

Postby Euclides » Wed Apr 21, 2021 1:21 pm

Hi Otto.
The same way...
Code: Select all  Expand view

  nkdnr := 10
  WinExec("CMD /C start chrome --new-window --app=https://test.com.space/formular/index.prg?recnr=" + ALLTRIM(STR( nkdnr )) + " --window-position=600,300  --window-size=1500,730",0)
 

It opened the window with the correct size but got DNS_PROBE_FINISHED_NXDOMAIN error.
But...
Code: Select all  Expand view

   WinExec("CMD /C start chrome --new-window --app=http://fivewin.com.br/index.php?/files/ --window-position=600,300 --window-size=1500,730",0)
 

Opens the site OK but does not respect the window sposition and size parameters
With your program compiled, got the same DNS_PROBE_FINISHED_NXDOMAIN error.
Regards, Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Re: Question about WinExec()

Postby Otto » Wed Apr 21, 2021 4:36 pm

Hello Euclides,

Thanks, it works very well. I run the program in localhost.

I want to make my WINHOTEL extensions in the future with mod harbour since we can access the same databases.
Thanks again. The call is much safer now. No bat-file - which you can change - in between.

Best regards,
Otto
Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6322
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 65 guests