Question about WinExec()

Post Reply
User avatar
driessen
Posts: 1428
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium
Been thanked: 2 times

Question about WinExec()

Post by driessen »

Hello,

Why isn't this code working?

Code: Select all | Expand

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. 25.01 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
karinha
Posts: 8057
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 10 times
Contact:

Re: Question about WinExec()

Post by karinha »

Maybe:

Code: Select all | Expand

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


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
hua
Posts: 1079
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 3 times
Been thanked: 2 times

Re: Question about WinExec()

Post by hua »

Michel,
Maybe can try experimenting with ShellExecute()
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
driessen
Posts: 1428
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium
Been thanked: 2 times

Re: Question about WinExec()

Post by driessen »

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

IF FILE(nProg1 + "KILLOUT.BAT") ; DELETE FILE(nProg1 + "KILLOUT.BAT") ; ENDIFaOutFile := 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. 25.01 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Antonio Linares
Site Admin
Posts: 42833
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 167 times
Been thanked: 123 times
Contact:

Re: Question about WinExec()

Post by Antonio Linares »

very good!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8784
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 9 times
Contact:

Re: Question about WinExec()

Post by Enrico Maria Giordano »

driessen wrote:Hello,

Why isn't this code working?

Code: Select all | Expand

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
Euclides
Posts: 157
Joined: Wed Mar 28, 2007 1:19 pm

Re: Question about WinExec()

Post by Euclides »

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
driessen
Posts: 1428
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium
Been thanked: 2 times

Re: Question about WinExec()

Post by driessen »

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. 25.01 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
Otto
Posts: 6426
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 48 times
Been thanked: 14 times
Contact:

Re: Question about WinExec()

Post by Otto »

Hello Euclides,

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

Code: Select all | Expand

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
User avatar
Euclides
Posts: 157
Joined: Wed Mar 28, 2007 1:19 pm

Re: Question about WinExec()

Post by Euclides »

Hi Otto.
The same way...

Code: Select all | Expand

  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

   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
Otto
Posts: 6426
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 48 times
Been thanked: 14 times
Contact:

Re: Question about WinExec()

Post by Otto »

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
Post Reply