Introduction: Using Batch to Update Software
I needed some of my software that people use to update. To renew files, fix bugs, and upload new code. It took me a while but I figured out how to do it and now i'll share my knowledge with you..
!!READ ANY AND ALL TOOL TIPS ON THE IMAGES IF GIVEN IT CONTAINS USEFUL INFO!!
IN THE PICTURES THERE WILL BE A BATCH FILE, WE WILL NOT DO ANYTHING UNTIL THE LAST STEP.
Step 1: Version Controlling
Since updates to my software are online I need to update the version, we need to make a version-control to do this. So I went to dropbox and put a zip file with .txt that contained the version number of the current software. **The text file SHOULD AND MUST BE NAMED currentver.txt or the updater will not know what to look for.**
> currentver.txt should just contain the numbers x.x.x where x is the numbers of your version.
- Create a .txt file named currentver
- Add the version number of what will be the always current number. (Meaning when a new software comes out this number must change to that number.)
- Save the file
- Zip the txt file with any name for the .zip
- Open dropbox.xom
- Upload the zip to the dropbox folder
- Share the ZIP file.
- Copy The Link Given.
WHAT TO DO WITH THE LINK IS IN THE NEXT STEP
Step 2: Downloading the Content (For Future Reference)
This article should be used for future reference as all the code is at the last step.
Now we need to run code to download the dropbox link.
!!WHEN USING THE DROPBOX LINK CHANGE THE ?dl=0 TO ?dl=1 OR NOTHING WILL DOWNLOAD!!
bitsadmin /transfer myDownloadJob /download /priority normal https://www.dropbox.com/s/pathto/Files.zip?dl=1 %cd%\versionCont.zip > nul
Remember to change the url to YOUR given url.
The command bitsadmin should be pre-installed in Windows 7 and Windows 8 Machines. `bitsadmin` will download the file.
Step 3: Tools for Extracting the Content
You will need the 7zip command line executable. notably named 7za.exe. Click me to download! (Once it is downloaded you will need to extract it and put it with the batch file using the command!)
Step 4: Setting the Users Version
This part is really simple.
All you need to do is make a text file called ActiveContVer and put in the version.
So If im starting out my version would be 1.0.0 which I would put in this text file.
This will be the users version of the software. And this .txt file will update whenever the user downloads to the latest version.
Step 5: Write the Code!
Now that we are done getting all of the other required files lets write the code.
echo Make sure your computer is connected to the internet before continuing
echo Close this program if you are not connected to the internet.
echo Otherwise Press any key check for any updates
pause > nul
::Begins and checks if any files exist to remove problems cls echo checking for updates. echo please wait ... if exist %cd%\currentver.txt del %cd%\currentver.txt > nul if exist %cd%\versionCont.zip del %cd%\versionCont.zip > nul ping localhost -n 10 > nul
::Downloads content to chech the versions. bitsadmin /transfer myDownloadJob /download /priority normal https://www.dropbox.com/s/linkto/versionCont.zip %cd%\versionCont.zip > nul
:: Since 7za comes with the download
:: The 7z command will work echo please wait finalazing update checks. 7za e %cd%\versionCont.zip > nul
ping localhost -n 4 > nul
:: Cleans up the leftover zip del %cd%\versionCont.zip > nul
:: Checks to see if versions are same or diffrent
:: The command puts out an ERRORLEVEL that will be used to decide whether it needs to be updated or not.
fc %cd%\ActiveContVer.txt %cd%\currentver.txt > nul
if errorlevel 1 goto outOfDate
echo you are Up-To-Date!
echo You can close this and be on your way!
pause > nul
echoYou are out of date!
echo We will redirect you to the website.
pause > nul pause
Now for the https://www.dropbox.com/s/linkto/versionCont.zip Change the https://www.dropbox.com/s/linkto Part.
Step 6: FEEDBACK!! (PLEASE!!!!)
Understand that I make mistakes i'm a human!
I Would like to know if you do not understand something or you have errors and need some help I would be more than willing to help you!!
We have a be nice policy.
Please be positive and constructive.