[SCRIPT] FileBot.jar Auto Updater (Windows)

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

[SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Ithiel »

SCRIPT UPDATED 2014/02/23 (v1.4.1) | INSTRUCTIONS UPDATED 2014/02/23
-----------------------------------------------------------------------------------------------


Updating the filebot jar manually requires effort - not very much, but effort none the less... and for whatever reason, that there must be a way to automate it!

FileBot Auto Jar Updater:
- Download: https://github.com/CapriciousSage/cmdle ... pdater.cmd
- Preview: https://github.com/CapriciousSage/cmdle ... pdater.cmd


Prerequisites:
- Assumes FileBot is installed in "C:\Program Files\FileBot"
- Uses bitsadmin for downloading, which should be included in Windows XP SP2 and later*

* According to the Microsoft documentation I can find, anyway.. but it's definitely in Windows 7/8, lol.


Install:
- Download the cmd file from the link above
- Right click on the file, go to properties, click 'Unblock' on the general tab, then click 'OK'.
- Double click the file and wait a few seconds while it downloads the latest installer.
- No 3rd party tools or downloaders required (uses included Windows tools)
- Tool will rename your current filebot.jar file to filebot_old.jar (and delete any old filebot_old.jar files you have)
- An updated FileBot.jar should be automatically downloaded in its place.
- Once complete, you're good to go (you don't need to go and use the 'unblock' option from file properties either)
- A log file will be created here if you're curious: %tmp%\filebot_automatic_updater.txt


Troubleshooting:
- Make sure you actually installed FileBot in "C:\Program Files\FileBot" and that it otherwise 'works'.
- You will need to be logged into an Administrator account for this to work.
- If the script doesn't open/run correctly, try right clicking on it and selecting 'Run as Administrator'.


Notes:
- This file is created automatically during the setup of the Advanced Explorer Context Menu script (http://www.filebot.net/forums/viewtopic ... 222&p=7390)
- Downloader now uses foreground priority to dramatically improve download speed


--------------------------------------------------------------
Like what you see? Donate to FileBot via PayPal
There can be only one Power² User
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by rednoah »

If you can set your download tool to "Follow Redirects" you can simply things and let SF.net decide the best mirror for you:

e.g. with wget

Code: Select all

wget http://sourceforge.net/projects/filebot/files/filebot/HEAD/FileBot.jar
:idea: Please read the FAQ and How to Request Help.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Ithiel »

Yeah, I read that wget could handle the redirections on that one, however Microsoft's bitsadmin is a little less robust, and just has a cry about it, lol.
There can be only one Power² User
User avatar
bonelifer
Power User
Posts: 81
Joined: 23 Mar 2013, 18:27

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by bonelifer »

I've already done this, it even backs up the current one before updating. http://www.filebot.net/forums/viewtopic ... 4610#p4610
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Ithiel »

yuup - this one checks to see if it's running with elevated privileges (and relaunches as so if not already), backs it up as well, and creates a log file detailing what happened.

I was thinking of using curl wget for windows', but I was hoping to achieve it without needing any 3rd party tools, which after some tweaking - it now does :-)

Update: v1.1 - now downloads from central URL, rather than hard coded into a specific mirror.

As an added bonus, it seems that because of the way it downloads the file, you don't need to manually into the file properties and 'unblock' it like you would if you downloaded it via a browser :-)

(Updating OP Now)
There can be only one Power² User
Akki
Posts: 16
Joined: 27 Jun 2013, 21:16

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Akki »

This is great.
Akki
Posts: 16
Joined: 27 Jun 2013, 21:16

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Akki »

Sent you a pull request on GitHub.

For some reason on my system the script used to request admin privileges came back with "access denied" errors when it was created in the Temp folder, but I changed it to the same directory as the updater script and it works that way. I don't know how common my issue would be, but this might be a decent solution (especially because the file is deleted right away anyway).

The bigger issue was that if something went wrong with the download once, I was left with only the Filebot.jar.old file, and if something went wrong twice in a row (which is possible especially since I plan to use it with Task Scheduler) I was left without any Filebot.jar file at all. So i reverse the order of things. If something goes wrong with the download, everything stays the way it was. If the download is successful, the backup is made and old backups are deleted.

Hope this helps.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by rednoah »

That's pretty common, not sure if it's Windows doing it or your Anti-Virus but loading dll, or executing programs from the temp folders it often gets blocked. Anything in the Program Files folders generally never gets blocked.


If you do call it on a schedule make sure it only updates if the file has changed:
http://www.filebot.net/forums/viewtopic ... 7441#p6459

If you really wanna have it run every day I recommend using curl with -z option. Not sure if bitsadmin also has a sync option.
:idea: Please read the FAQ and How to Request Help.
Akki
Posts: 16
Joined: 27 Jun 2013, 21:16

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Akki »

rednoah wrote:That's pretty common, not sure if it's Windows doing it or your Anti-Virus but loading dll, or executing programs from the temp folders it often gets blocked. Anything in the Program Files folders generally never gets blocked.


If you do call it on a schedule make sure it only updates if the file has changed:
http://www.filebot.net/forums/viewtopic ... 7441#p6459

If you really wanna have it run every day I recommend using wget with -z option.
Well, I don't run an AV other than Windows Defender (which is MSE on Windows 8), so I don't think it's that. I think it has something to do with the way permissions work, which I think Microsoft actually tweaked somewhat for Win8. But yeah, that's why I changed the script to put the admin privileges request script in the same folder as the updater script itself, which seems to work fine (even though I don't have it in Program Files, tough maybe I should).

As far as only updating when the file has changed, I'm not sure if that's possible with BITSAdmin. The whole point of this script seems to be not needed to use any other utility that's not built into Windows, so I don't know if that would be possible with this. I am considering just biting the bullet and downloading curl (certainly not the worst utility to have), but for those who don't want to (which is why Ithiel made this script, I guess), I just submitted some changes to make sure that it's a little more robust.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by rednoah »

If someone figures how to do sync with bitsadmin even better :D
:idea: Please read the FAQ and How to Request Help.
Akki
Posts: 16
Joined: 27 Jun 2013, 21:16

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Akki »

rednoah wrote:If someone figures how to do sync with bitsadmin even better :D
Absolutely. Unfortunately, it seems that BITSAdmin is pretty barebones as far as actual downloading options are concerned. It's got plenty of features for managing download jobs, which seems to be its main purpose, but the actual download part itself is too straightforward.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Ithiel »

UPDATE: FileBot Auto Jar Updater v1.2
- Compatibility improvements added by Akki.

Thanks Akki, looks good :-)

Unfortunately, I can't see anything in bitsadmin that allows for version control like that. The only way would be to check it after you've downloaded it, at which point such tasks are a little redundant, lol.
There can be only one Power² User
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Ithiel »

UPDATE: FileBot Auto Jar Updater v1.4
- Further improved compatibility post-integration into context menu installer.
There can be only one Power² User
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: [SCRIPT] FileBot.jar Auto Updater (Windows)

Post by Ithiel »

UPDATE: FileBot Auto Jar Updater v1.4.1
- Downloader now uses foreground priority to dramatically improve download speed.
There can be only one Power² User
Post Reply