Page 1 of 1
Shellexecute(), Waitrun(), Winexec() - solved
Posted: Wed Oct 20, 2010 2:11 pm
by driessen
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
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.
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 2:14 pm
by Enrico Maria Giordano
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
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 2:18 pm
by driessen
Enrico,
I'm quite sure indeed.
I tried both like this
Code: Select all
WinExec("MSXML.MSI",1)
WaitRun("MSXML.MSI",2)
and nothing happens.
Thanks.
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 2:30 pm
by Richard Chidiak
Michel
You need to indicate the whole path
waitrun("c:\.....\msxml.msi")
Richard
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 3:11 pm
by driessen
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.
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 3:43 pm
by fp
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
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 3:51 pm
by driessen
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.
Re: Shellexecute(), Waitrun(), Winexec()
Posted: Wed Oct 20, 2010 8:35 pm
by James Bott
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
Re: Shellexecute(), Waitrun(), Winexec() - Solved
Posted: Wed Oct 20, 2010 9:42 pm
by driessen
James,
Thank you very much for your help.
This code did its job :
Code: Select all
WaitRun("msiexec.exe /i c:\temp\msxml.msi")
Thank you so much.