AutoUpdate Vb.net

EriX920

Respected
I need someone to write me a fast and clean way of updating my app.

Heres what I wrote in a minute, I just have so much shit to write for my app I can't do it all.

Code:
    Private Sub autoup()

        Try
            My.Computer.Network.DownloadFile("http://www.ecct2.freesteam.org/ecc/version.txt", "version.txt")
        Catch ex As Exception
            MsgBox(ex)
            Exit Sub
        End Try

        Dim vrspth As String = "version.txt"
        Dim vrs As String
        Dim objReader As StreamReader
        objReader = New StreamReader(vrspth)
        vrs = objReader.ReadToEnd()
        objReader.Close()

        If My.Application.Info.Version.ToString < vrs.ToString Then
            MsgBox("Updated available!")
            ' Do update, maybe call a secondary app to start, close this app
            ' delete old copy or rename and download new and then start it.
        End If

    End Sub
 
Simple and effective. I have made many different auto-updates all with different ways of checking for updates and getting them each time lol.
 
Well I meant like doing what did, download and check the text file. Not like checking system time, having it show a progress bar / download speed etc..
 
Well, I use another executable for updating the application, so the main app checks for updates then sends the update query for the updater then closes, the updater waits for it to exit then it downloads the updates. I may send ya teh source....


EDIT:

See if this helps:

http://www.codeproject.com/KB/vb/au...mpp=25&noise=3&sort=Position&view=Quick&fr=26
http://www.codeproject.com/KB/cs/Net_AutoUpdaterTemplate.aspx
http://www.google.co.uk/search?num=100&hl=en&q=.NET+AutoUpdater&btnG=Search&meta=
 
First link is exactly what I meant by too complicated.

I can just close the program by:

Code:
Private Sub kill(Byval proc As String)
        Dim inst As Process
        Dim klpc As Process() = Process.GetProcessesByName(proc)
        For Each inst In klpc
            inst.Kill()
        Next
End Sub

So that isn't a problem. I've ran into a really annoying bug in my server so i'm trying to fix that. If you want to build onto that, please do ;).
 
Hi could anyone help with a auto updater, ive tried all the codes found on the internet but none seem to work, my version .txt is Here but it doesnt seem to work, i made a if statment saying if that file has a length less than 7 then it should come up with an error, so it always comes up with an error, what i want is a form which says the current program version (label1.text) and the most updated version (label2.text) and if label1 is less that label2 it would download then close the current program, rename the old program move the new one into that dir and then delete the old one

when i try the original code from that guy i get no error but a debug error which doesnt say what it is or how to fix
 
KZON3 said:
I have seen something similar in C# and have yet to physically code it. The coding process should be the similar but you need to do a bit of language conversion.

Code:
http://themech.net/2008/05/adding-check-for-update-option-in-csharp/

Code:
//Basically, load your text file data in as parameter.
Version newVersion = new Version(reader.Value);

//After that, get the current version of your running app from the assembly.
Version curVersion =  System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

//Use this if statement to compare if current version is older than the new version(obtained string from the net).
if (curVersion.CompareTo(newVersion) < 0)

//Perform download, start anonymous process, kill old process, rename to original name, execute process. Hopefully I didn't get any of it wrong.
 
Hi guys,

I may post the auto updater part of my YASAMM it does the following:-

1. YASAMM contacts the HTTP Update Server (written in PHP on Apache)
2. HTTP Server responds with the current version
3. If version is out of date YASAMM asks the user whether to update or not
4. If update is accepted then YASAMM does a slow HTTP download :rolleyes: from the server using "PRIMITIVE" requests and stores the block in an internal buffer
5. YASAMM then loads update file to "temp" folder on disk, it also loads it's internal launcher to "temp" folder and launches it.
6. The launcher waits until YASAMM has terminated and then deletes YASAMM, renames the update file and copies it to the original folder
7. The Launcher then launches the new YASAMM and exits
8. The updated YASAMM starts

YASAM is about 2.5 MB and totally self contained so the above scenario works well for it but may not be suitable for others - although the Launcher may be.

This is all in Win32 C++ - I was considering posting this in snippets and listening to any suggested improvements.

cheers
OldFart

The notes below may be a bit cryptic but I hope they convey enough information to make sense ..

Notes: Usage parameters (primitives)
-d => delete file
-r => rename file (from to)
-c => copy (from to)
-e => execute (exe + command line + parameters fed to exe)

Code:
 ------------------------------------------------------------------------
//		Notes:
//
//	vnetcafeupdater -d file_a.txt -r file_b.txt file_e.txt -c file_c.txt test_out/file.c -e "" "dir test_out"
//
//  ------------------------------------------------------------------------

Interface Header

Code:
//	-------------------------------------------------------------
//
//		Defines & Typedefs
//
//	-------------------------------------------------------------
#define	GLOBAL
#define	LOCAL	static

#define	UPD_PARAM_COPY		"-C"
#define	UPD_PARAM_DELETE	"-D"
#define	UPD_PARAM_EXECUTE	"-E"
#define	UPD_PARAM_MKDIR		"-MD"
#define	UPD_PARAM_RENAME	"-R"
#define	UPD_PARAM_RMDIR		"-RD"

#define	CMD_COPY			"C"
#define	CMD_DELETE			"D"
#define	CMD_EXECUTE			"E"
#define	CMD_MKDIR			"MD"
#define	CMD_RENAME			"R"
#define	CMD_RMDIR			"RD"

//	-------------------------------------------------------------

And invocation

Code:
//	**************************************************************************
//	**                                                                      **
//	**                                                                      **
//	**                                                                      **
//	**      Name:  UTILITY FUNCTIONS                                        **
//	**                                                                      **
//	**      Description:                                                    **
//	**                                                                      **
//	**                                                                      **
//	**      Parameters:                                                     **
//	**                                                                      **
//	**                                                                      **
//	**		Returns:                                                        **
//	**                                                                      **
//	**                                                                      **
//	**                                                                      **
//	**                                                                      **
//	**************************************************************************
void CUpdateViaHttp::LaunchUpdate()
{
	CFile	tFile;
	DWORD	dwLastError;
	BOOL	fRC	= FALSE;
	CString	csCommandLine;

	char	*pszTempName	= NULL;

	pszTempName	= _tempnam((char *)(LPCTSTR) m_csLoaderBaseDir, m_csFname );

	//	--->	--------------------------	<---
	//	--->	Validate call to tempnam()	<---
	//	--->	--------------------------	<---
	if	( pszTempName != NULL )
	{
//		_splitpath( pszTempName, 
//					szDrive,
//					szDir,
//					szFname,
//					szExt );
//		csApplicationDir	= szDrive;
//		csApplicationDir	+= szDir;

		//	Save the temp file name
		m_csTempPath	= pszTempName;

		//	--->	---------------	<---
		//	--->	Load the loader	<---
		//	--->	---------------	<---
		fRC	= CreateLoaderFile( LOADER_FILENAME );
		if	( fRC == TRUE )
		{
			//	--->	---------------------------------	<---	
			//	--->	Copy from internal to Destination	<---
			//	--->	---------------------------------	<---
			fRC	= tFile.Open( pszTempName, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive | CFile::typeBinary );
			if	( fRC )
			{
				tFile.Write( m_pabClientDownloadFileData, m_dwClientDownloadFileSize );
				tFile.Close();
				//fRC	= TRUE;
				//	Temp Files is loaded - Now create 
				//					  loader  -D xx -R sr dn -E ex cl
				csCommandLine.Format( "\"%s\" %s \"%s\" %s \"%s\" \"%s\" %s \"%s\" %s",
					m_csLoaderFilePath,
					UPD_PARAM_DELETE, m_csClientFullPathName,
					UPD_PARAM_RENAME, m_csTempPath, m_csClientFullPathName,
					UPD_PARAM_EXECUTE, m_csClientFullPathName, "\"\"" );

				//	Create Loader Command Line
				fRC	= LaunchLoader( (char *)(LPCTSTR)m_csLoaderFilePath, 
									(char *)(LPCTSTR)csCommandLine,
									(char *)(LPCTSTR)m_csLoaderBaseDir );
				if	( fRC == TRUE )
				{
					//	Launch is successful
					PostMessageToParent( ExitNow, 0 );
					PostQuitMessage( 0 );
				}
				else
				{
					unlink( pszTempName );
//				}
#				ifdef	LOG_ENABLE
//				else
//				{
					//dwLastError	= GetLastError();
					ON_LOG_ERROR( va_string( " ** Launch Loader FAILS\n" ));
//				}
#				endif	//ifdef	LOG_ENABLE
				}
			}
#			ifdef	LOG_ENABLE
			else
			{
				dwLastError	= GetLastError();
				ON_LOG_ERROR( va_string( " ** Create Temp File FAILS (%ld)\n", dwLastError ));
			}
#			endif	//ifdef	LOG_ENABLE
		}
#		ifdef	LOG_ENABLE
		else
		{
			dwLastError	= GetLastError();
			ON_LOG_ERROR( va_string( " ** CreateLoaderFile FAILS (%ld)\n", dwLastError ));
		}
#		endif	//ifdef	LOG_ENABLE
	}
#	ifdef	LOG_ENABLE
	else
	{
		dwLastError	= GetLastError();
		ON_LOG_ERROR( va_string( " ** Create Temp Name fails (%ld)\n", dwLastError ));
	}

//	ON_LOG_FUNCTION( va_string( "<-- CUpdateClient::UpdateClient( %s, %p, %ld )\n", pszApplicationPath, pbDownloadBuffer, dwDownloadSize));
#	endif	//ifdef	LOG_ENABLE

//	return	fRC;

}
 
Back
Top