Link to home
Create AccountLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

avoid browser issues during an update

Here is some VB6 code I am using.  When it is time to update my program, I run this code to force people to download an update.

I want to avoid browser issues.  Will this code do that for me?



ShellExecute Form1.hwnd, "Open", "http://mysite/Setup.exe", "", "", SW_SHOWNORMAL

Inet1.Execute , "Setup.exe"
Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

This looks like an InstallShield or NSIS package..  You should be able to wrap this into a DOS Shell unless you have a memory constraint on running your package..

HTH,

Kent
Is the setup.exe program updating the program that is executing?  if so, I don't think it will work.  Have you tried it and do you get any specific errors?
ASKER CERTIFIED SOLUTION
Avatar of shorvath
shorvath
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of al4629740

ASKER

The problem I ran into before is that when they would download my Setup.exe file with the following code, they would have a cached Setup.exe file from before in their browser.  Then they would endlessly be downloading my file in a "loop" because it was never really downloading the new file.

See below

'Checking for latest version-----------------------------
cdata = Inet1.OpenURL("http://www.chicagoareaproject.org/version.txt", 0)


If cdata > 10.2 Then
Splash3.Hide


If MsgBox("An UPDATE has been posted.  You must click YES to re-download the program in order to proceed.  Would you like to download it now?", vbYesNo Or vbQuestion, "Download new version?") = vbYes Then
    ShellExecute Form1.hwnd, "Open", "http://www.mysite.com/Setup.exe", "", "", SW_SHOWNORMAL
    End
    Else
    MsgBox ("Program will not begin until update is downloaded.")
    End
End If

End If
I am a little confused as to what to do here in the FTP code you gave:

   ' download welcome.txt and place it on c:\welcome.txt
   Inet1.Execute , "GET welcome.txt c:\welcome.txt"
   Do While Inet1.StillExecuting
      DoEvents
   Loop
   Inet1.Execute , "CLOSE"


How do I get my Setup.exe to execute?  Can you show me using another example?
Sorry, I'm good at confusing things...

Basically, I don't know how to use the FTP code you gave above to call the Setup.exe program.
Do you have access to the server that stores the file?  
If so, setup an FTP server, and use the code in the sample.

   Inet1.AccessType = icUseDefault
   Inet1.URL = "ftp://10.132.3.190"        '<---- put the your servers IP Address Here
   Inet1.UserName = "anonymous"        '<---- put your UserName Here
   Inet1.Password = "your_password"     '<---- put your Password Here
   
   Inet1.RequestTimeout = 40                '<---- # of seconds to reach your server
 


   Inet1.Execute , "GET Setup.exe c:\Setup.exe"

'Use the GET statement to pull the Setup.exe to the local machines C: drive.
'You can put it anywhere on the local machine as long as the path you specify exists.

'Loop until the Download is complete, then close the connection.

   Do While Inet1.StillExecuting
      DoEvents
   Loop
   Inet1.Execute , "CLOSE"

Once the Download is complete, use the ShellExecute API to run the Setup.exe

Const SW_SHOWNORMAL = 1

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
   "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
   ByVal lpFile As String, ByVal lpParameters As String, _
   ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute Me.hwnd, "open", "C:\setup.exe", "", "C:\", SW_SHOWNORMAL