Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collect updated executable from my server 3

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
Further to thread184-1658529

I have experimented with the download options shown in the above and related threads.

I would like to ask the forum if my idea is practicable before I spend a lot more time getting it to work.

The spending of hundreds of dollars on a 3rd party solution is not warranted.

After clicking on a button in my app to Upgrade.

1 D/L upgrade.bat to C:\temp
2 D/L new app Setup executable to C:\temp
3 Run upgrade.bat which would copy the new app executable setup installer to the PF folder it belongs in.
4 Close my app
5 Open again using latest exe ( using opening routine already in the code)- possibly deleting old exe when it starts up.

Thanks for your comments


GenDev
 
I am not sure why you are attempting to use the DLL and BAT file approach.

There is a very good approach that I have used at client sites for years.
An Application starter (with auto copy from server into local station). faq184-4492

Unless there is something else that is not identified that you need, it would appear to do all that you want.

1. Check for an Updated version of the EXE in another location.
2. If Update present, it will Download the latest version to the workstation.
3. It will then launch the current version (i.e. latest version) of the EXE.

Yes I had to 'tweak' the FAQ code a little, but not much.

clicking on a button in my app to Upgrade.

This approach does not depend on someone manually clicking on a button. It will automatically check and update when the application initially launches. That is a much better guarantee that the user will be running the latest code than if things depended on a user's manual action.

Good Luck,
JRB-Bldr

 
Jrbbldr,

I am distributing my app apdate across the Internet - I don't think ramanai's code does that.

Thanks

GenDev
 
Dan,

Thanks for the link to that interesting paper - I will have to see whether I have enough skills/understanding to get into it.

GenDev
 
Wtch out for UAC in Windows 7, it makes this whole update process a smidge more complicated.

If it spots what you are doing, it will 'elevate' your status to administrator (whereby your drive mappings may no longer be the same) and make it impossible to download your app.

And... batch files make this process look very amateurish

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
GenDev,

I have been working on the same problem this last couple of weeks. The solution I have adopted is to use a third-party product called Software Update Wizard.

I know you said you don't want to spend "hundreds of dollars" on a third-party product. Like you, I also have budget constraints for this project. But the product in question isn't all that expensive, and I reckon it saved me several days of programming. In particular, it solved the Windows 7 problems that Griff referred to.

I have written up some technical details of this product and some sample FoxPro code: Using the Software Update Wizard with Visual FoxPro.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Here's the process we use in Stonefield Query, which works in all versions of Windows including Vista and 7:

- Download the update to a writable folder (eg. user's temp folder)

- If Windows Vista or later (check using OS(3)) and the user isn't running the app as administrator (check using IsAdminUser API function), tell the user they're about to see a UAC dialog so they aren't surprised.

- If the user is running the app as administrator, use ShellExecute to run SQUPDATE.EXE (see next point). Otherwise, use ShellExecute with "RunAs" to force elevation (required to copy files into Program Files folders). Then QUIT.

- SQUPDATE.EXE copies the downloaded files to the current directory, then restarts the main EXE and quits.

- The main EXE now starts up as the new version.

Doug
 
Doug

If you force a "RunAs" when that program then restarts the original .exe is it no longer elevated?

If you let W7 elevate you, and then run another program it is run at the same elevation

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Doug,

Were you able to point me to the code for your system? My app is very inexpensive and doesn't warrant a big expense.

I'm more interested in learning how it's done and whether I can make it work.

GenDev
 
Hey Griff.

Yes, unfortunately that's one downside but I don't know how to get around it, other than not letting the updater EXE relaunch the main EXE, which is a pain for the user.

Doug
 
Hi GenDev.

Most of the code is pretty straightforward: copying files from one folder to another. The key is using the ShellExecute API function (see for the syntax) using "RunAs" for the second parameter to launch the updated EXE so it can be elevated and have permissions to write to folders in Program Files.

Doug
 
What I do is quit the updater, after showing a message to the effect that this is all M$s fault - but they have to reload the app!

Very disappointing

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
The third-party tool I mentioned avoids the problem by running as a Windows service. Because it runs in the SYSTEM security context, UAC isn't an issue. The disadvantage is that it's one more service that runs the whole time on your system, even though you might only use it once a year.

(By the way, I'm not trying to promote this product in any way. I only mentioned it again here because it offers a different approach to this common problem.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top