Shellexecute(), Waitrun(), Winexec() - solved

Shellexecute(), Waitrun(), Winexec() - solved

Postby driessen » Wed Oct 20, 2010 2:11 pm

Hello,

I need to run a MSI-file (Microsoft Installer) from my application and I want my application to wait until the installation has been finished.

Waitrun() and Winexec() cannot be used since they don't work with a MSI-file.

So I try to use ShellExecute()

This is the code :
Code: Select all  Expand view
ShellExecute(,"Open","MSXML.MSI",,,3)
SYSWAIT(5)
DO WHILE .T.
   hFile := FOPEN("MSXML"+IF(IsWin7(),"6","4")+".MSI",FO_READWRITE + FO_EXCLUSIVE)
   IF FERROR() <> 0
      SYSREFRESH()
      SLEEP(1)
      LOOP
   ENDIF
   FCLOSE(hFile)
   EXIT
   SYSREFRESH()
ENDDO

Unfortunately, my application doesn't wait until the installation has been finished.

How can I solve this problem?

Thanks you.
Last edited by driessen on Wed Oct 20, 2010 9:43 pm, edited 1 time in total.
Regards,

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

Re: Shellexecute(), Waitrun(), Winexec()

Postby Enrico Maria Giordano » Wed Oct 20, 2010 2:14 pm

driessen wrote:Waitrun() and Winexec() cannot be used since they don't work with a MSI-file.


Are you sure? I never tried for myself but I can't see why they shouldn't work.

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

Re: Shellexecute(), Waitrun(), Winexec()

Postby driessen » Wed Oct 20, 2010 2:18 pm

Enrico,

I'm quite sure indeed.

I tried both like this
Code: Select all  Expand view
WinExec("MSXML.MSI",1)

WaitRun("MSXML.MSI",2)
and nothing happens.

Thanks.
Regards,

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

Re: Shellexecute(), Waitrun(), Winexec()

Postby Richard Chidiak » Wed Oct 20, 2010 2:30 pm

Michel

You need to indicate the whole path

waitrun("c:\.....\msxml.msi")

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Shellexecute(), Waitrun(), Winexec()

Postby driessen » Wed Oct 20, 2010 3:11 pm

Richard,

I tried them out with the full path, but no luck. The result is exactly the same.

But now I check which message was returned.

Waitrun() returns -1
WinExec() return 11 which means that the executable file was invalid.

But if I launch the MSI-file manually, everything goes fine.

Thanks anyway.
Regards,

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

Re: Shellexecute(), Waitrun(), Winexec()

Postby fp » Wed Oct 20, 2010 3:43 pm

I tryed this with no problems:

ShellExecute(,"Open","MSXML.MSI",,,3)
SYSWAIT(5)
DO WHILE .T.
hFile := FOPEN("MSXML.MSI",FO_READWRITE + FO_EXCLUSIVE) // !!!
IF FERROR() <> 0
SYSREFRESH()
SLEEP(1)
LOOP
ENDIF
FCLOSE(hFile)
EXIT
SYSREFRESH()
ENDDO
Frank-Peter
User avatar
fp
 
Posts: 76
Joined: Fri Dec 30, 2005 10:25 am
Location: Germany

Re: Shellexecute(), Waitrun(), Winexec()

Postby driessen » Wed Oct 20, 2010 3:51 pm

Thanks a lot for your reply.

I know that this is working. But I need my application to wait until the installation has been finished. And that doesn't happen. My application just goes on.
Regards,

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

Re: Shellexecute(), Waitrun(), Winexec()

Postby James Bott » Wed Oct 20, 2010 8:35 pm

Michel,

Try this:

waitrun( "msiexec.exe c:\temp\msxml.msi /I /QN")

For more details on command line options:
http://www.appdeploy.com/articles/commandline.asp

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Shellexecute(), Waitrun(), Winexec() - Solved

Postby driessen » Wed Oct 20, 2010 9:42 pm

James,

Thank you very much for your help.

This code did its job :
Code: Select all  Expand view
WaitRun("msiexec.exe /i c:\temp\msxml.msi")


Thank you so much.
Regards,

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


Return to FiveWin for Harbour/xHarbour

Who is online

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