MJ Service Autoupdate Script
Moderators: Pilot, Bill Smith
MJ Service Autoupdate Script
********************
25 Dec 08: Changed the mjupdate script to remove hammering of MJ's servers. Expect another update to keep us from running update over and over again when it isn't updated.
23 June 08: Added "/f" to terminate magicjack.exe in terminate.bat
19 June 08: Changed CDLoader script...no need for extra .reg file. Terminate.bat changed.
18 June 08: Adds CDLoader removal script
********************
I said I'd bring it to you and here it is. Unfortunately, this is built off of FireDaemon but should work on other scripts. This script is usable for scheduling an update nightly...while it's doing this, the service will be down...this takes about 10 mins. It's very possible to run the script separately, but this will cause some problems with multiple magicjack services. Again, you can run this as a startup script, but this will keep MJ down for however long it takes to download an 9mb file.
Service Requirements (Firedaemon covers these):
Scheduler capable
Batch capable
someone let me know if the one at http://carpcnet.com/modules.php?name=Do ... ils&lid=79 works.
That being said, here it is:
*notes:
*I keep this in my original user folder as that's the server profile
*This is Vista profile paths. XP differs
*******Updated 25 Dec 2008*******
I created a batch file named mjupdate.bat with the following lines:
cd C:\Users\Trebuin\AppData\Roaming\mjusbsp\
attrib -h *.* /s /d
md C:\Users\Trebuin\AppData\Roaming\mjusbspbak\
copy *.* C:\Users\Trebuin\AppData\Roaming\mjusbspbak\
rem del *.* /s /q (no longer need to delete everything)
Copy upgrade.exe upgrade.old
rem (for future comparison when I find the right command)
c:\"program files (x86)"\gnuwin32\bin\wget.exe -N http://upgrades.magicjack.com/upgrade/upgrade.exe
upgrade.exe
REM This will always run so the next command is REM'ed
REM C:\Users\Trebuin\AppData\Roaming\mjusbsp\magicjackloader.exe /scf _magicJackPersonalDataRoot "E:\magicJack"
I then created a termination file terminate.bat with the following lines:
taskkill /im magicjack.exe /t /f
taskkill /im magicjackloader.exe /t
taskkill /im magicjacksplash.exe /t
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v cdloader /f
I then created the services:
Original MJ service was not changed except running times: Start: 1:57 AM End: 1:29 AM
mjupdate.bat service: Start 1:30 AM End: 1:55 AM (disabled auto-restart)
terminate.bat service: Start 1:56 AM End 1:56:30 AM (disabled auto-restart)
*************End of instructions**************
This allows MJ to run normally during the day. The update will always delete the previous update files. MJ should always update when there's an update, but I have found this was not the case. By deleting the previous files, MJ will do a full install...which targets the current update. The downside is that this will hammer MJ's update server (updated 25 Dec 08: no longer will hammer MJ's servers. Sorry this took so long). The update takes around 4 minutes for me. After it's completed, with the /scf, magicjack will run normally, thus minimizing the downtime. The terminate script has to be run because MJ will not shut down because the service targets the bat.
I created the backup folder to provide the ability to still run MJ should the update fail. If MJ hangs during the update, MJ will not function until the standard MJ script runs. The terminate has all MJ possible services to account for hanging situations.
***Letter To Magicjack: please create an independent update file that checks to see and installs magicjack's updates. Please let me know.
Feel free to post improvements and discuss this. I'll try to keep this up to date, but keep in mind I can get busy.
Respectfully,
Treb
25 Dec 08: Changed the mjupdate script to remove hammering of MJ's servers. Expect another update to keep us from running update over and over again when it isn't updated.
23 June 08: Added "/f" to terminate magicjack.exe in terminate.bat
19 June 08: Changed CDLoader script...no need for extra .reg file. Terminate.bat changed.
18 June 08: Adds CDLoader removal script
********************
I said I'd bring it to you and here it is. Unfortunately, this is built off of FireDaemon but should work on other scripts. This script is usable for scheduling an update nightly...while it's doing this, the service will be down...this takes about 10 mins. It's very possible to run the script separately, but this will cause some problems with multiple magicjack services. Again, you can run this as a startup script, but this will keep MJ down for however long it takes to download an 9mb file.
Service Requirements (Firedaemon covers these):
Scheduler capable
Batch capable
someone let me know if the one at http://carpcnet.com/modules.php?name=Do ... ils&lid=79 works.
That being said, here it is:
*notes:
*I keep this in my original user folder as that's the server profile
*This is Vista profile paths. XP differs
*******Updated 25 Dec 2008*******
I created a batch file named mjupdate.bat with the following lines:
cd C:\Users\Trebuin\AppData\Roaming\mjusbsp\
attrib -h *.* /s /d
md C:\Users\Trebuin\AppData\Roaming\mjusbspbak\
copy *.* C:\Users\Trebuin\AppData\Roaming\mjusbspbak\
rem del *.* /s /q (no longer need to delete everything)
Copy upgrade.exe upgrade.old
rem (for future comparison when I find the right command)
c:\"program files (x86)"\gnuwin32\bin\wget.exe -N http://upgrades.magicjack.com/upgrade/upgrade.exe
upgrade.exe
REM This will always run so the next command is REM'ed
REM C:\Users\Trebuin\AppData\Roaming\mjusbsp\magicjackloader.exe /scf _magicJackPersonalDataRoot "E:\magicJack"
I then created a termination file terminate.bat with the following lines:
taskkill /im magicjack.exe /t /f
taskkill /im magicjackloader.exe /t
taskkill /im magicjacksplash.exe /t
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v cdloader /f
I then created the services:
Original MJ service was not changed except running times: Start: 1:57 AM End: 1:29 AM
mjupdate.bat service: Start 1:30 AM End: 1:55 AM (disabled auto-restart)
terminate.bat service: Start 1:56 AM End 1:56:30 AM (disabled auto-restart)
*************End of instructions**************
This allows MJ to run normally during the day. The update will always delete the previous update files. MJ should always update when there's an update, but I have found this was not the case. By deleting the previous files, MJ will do a full install...which targets the current update. The downside is that this will hammer MJ's update server (updated 25 Dec 08: no longer will hammer MJ's servers. Sorry this took so long). The update takes around 4 minutes for me. After it's completed, with the /scf, magicjack will run normally, thus minimizing the downtime. The terminate script has to be run because MJ will not shut down because the service targets the bat.
I created the backup folder to provide the ability to still run MJ should the update fail. If MJ hangs during the update, MJ will not function until the standard MJ script runs. The terminate has all MJ possible services to account for hanging situations.
***Letter To Magicjack: please create an independent update file that checks to see and installs magicjack's updates. Please let me know.
Feel free to post improvements and discuss this. I'll try to keep this up to date, but keep in mind I can get busy.
Respectfully,
Treb
Last edited by Trebuin on Thu Dec 25, 2008 8:27 am, edited 4 times in total.
For those who have tried this and did not create a .reg file, update your script.
The original updater re-enables the cdloader again. I updated the terminate.bat file to run a reg file with the following command:
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"cdloader"=-
This allows terminate.bat to delete that and keeps the cdloader from running every boot. Enjoy!
The original updater re-enables the cdloader again. I updated the terminate.bat file to run a reg file with the following command:
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"cdloader"=-
This allows terminate.bat to delete that and keeps the cdloader from running every boot. Enjoy!
Thanks for the command so we don't have to build that .reg file. The magicjackloader.exe has to be used for the update. If you just use magicjack.exe, it bypasses checking for updates completely. You can verify this by creating a backup copy of the batch file, stopping the MJ service, then running the batch file with magicjack.exe. Check your subfolders...magicjack will run, but nothing will be downloaded to these folders.semicharm wrote:Two things:
You can use the REG command from the batch script to do the necessary registry edit like this:
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v cdloader /f
Also, any reason for using magicjackloader.exe rather than magicjack.exe?
Thanks for the script change...I'll add this.
It's totally iffy. My server was probably set up the same way but it never took any update. Turns out that the recent push killed my MJ so I had to use the loader. This updated it without a problem. Unfortunately, it is totally random when it updates if those previous files are there. Anyhow, this forces the update nightly, but waists extra BW.
-
- Dan isn't smart enough to hire me
- Posts: 187
- Joined: Sun Dec 07, 2008 9:03 pm
Thanks,
Nice work.
Also, it's worth to mention that Wget for Windows can be downloaded from sourceforge.
http://gnuwin32.sourceforge.net/packages/wget.htm
This would at least be true for XP users, but most likely even for Vista users, in order to be able to execute the command
As for the file comparison you always have the DOS-version "FC /B fileA fileB", but a quicker and more elegant way would most likely be to compare the MD5 checksum. i.e. md5 Command Line Message Digest Utility
http://www.fourmilab.ch/md5/
it returns the value 0 if the two sums are equal.
Nice work.
Also, it's worth to mention that Wget for Windows can be downloaded from sourceforge.
http://gnuwin32.sourceforge.net/packages/wget.htm
This would at least be true for XP users, but most likely even for Vista users, in order to be able to execute the command
Code: Select all
c:\"program files (x86)"\gnuwin32\bin\wget.exe -N http://upgrades.magicjack.com/upgrade/upgrade.exe
http://www.fourmilab.ch/md5/
it returns the value 0 if the two sums are equal.
-
- Dan isn't smart enough to hire me
- Posts: 470
- Joined: Wed Apr 02, 2008 11:45 pm
- Location: Dallas, TX
Nice work and great idea. I've made some changes to your script which should make it a little more universal.
EDIT: Don't use this yet as it needs some more tweaking.
The assumption is that you are running MJ in service mode already and the service is called "magicjack".
You will need to download the wget for windows and extract it in a folder called MJautoupdate. Create a batch file called MJupdate.bat and put the commands below in it. If your service is called something other than "magicjack" then change the name at the beginning and end of the script.
Copy this whole MJautoupdate folder into your mjusb folder. Create a scheduled task to run this batch file whenever you want.
EDIT: Don't use this yet as it needs some more tweaking.
The assumption is that you are running MJ in service mode already and the service is called "magicjack".
You will need to download the wget for windows and extract it in a folder called MJautoupdate. Create a batch file called MJupdate.bat and put the commands below in it. If your service is called something other than "magicjack" then change the name at the beginning and end of the script.
Copy this whole MJautoupdate folder into your mjusb folder. Create a scheduled task to run this batch file whenever you want.
Code: Select all
net stop magicjack
cd ..
attrib -h *.* /s /d
md ..\mjusbspbak\
copy *.* ..\mjusbspbak\
Copy upgrade.exe upgrade.old
.\MJAutoUpdate\wget.exe -N http://upgrades.magicjack.com/upgrade/upgrade.exe
upgrade.exe
taskkill /im magicjack.exe /t /f
taskkill /im magicjackloader.exe /t
taskkill /im magicjacksplash.exe /t
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v cdloader /f
net start magicjack
-
- Dan isn't smart enough to hire me
- Posts: 470
- Joined: Wed Apr 02, 2008 11:45 pm
- Location: Dallas, TX
Script Completed - 1,1 Version
Scratch what I was trying to do above as I have a much more refined solution. I took the great idea Trebuin started out with and came up with a very nice app IMO 
I have all the files you need (hopefully) zipped up. I have made several versions that should work regardless if you are running MJ as a service or in the regular native mode.
Basically, this will check to see if you are running the most current version of MJ. If not, it will download the upgrade.exe from the MJ servers and run it. Once completed it will restart MJ for you.
Read More here - LINK

I have all the files you need (hopefully) zipped up. I have made several versions that should work regardless if you are running MJ as a service or in the regular native mode.
Basically, this will check to see if you are running the most current version of MJ. If not, it will download the upgrade.exe from the MJ servers and run it. Once completed it will restart MJ for you.
Read More here - LINK
Last edited by stroths on Tue Dec 30, 2008 1:42 pm, edited 2 times in total.
-
- Dan isn't smart enough to hire me
- Posts: 187
- Joined: Sun Dec 07, 2008 9:03 pm
Good idea. The only reason why I put the split in is that I saw some problems occur if it shut down too fast after update.exe was finished. So I simply made a second batch that would run a few mins later to assure it had time. I guess another method to solve this would be to ping the localhost for a little bit. There's many ways to skin this cat. Thanks for the exe and keep in touch. If I can, I'd love to add some tweaks that keeps it from autoupdating to a non-function version, ect.stroths wrote:Nice work and great idea. I've made some changes to your script which should make it a little more universal.
EDIT: Don't use this yet as it needs some more tweaking.
The assumption is that you are running MJ in service mode already and the service is called "magicjack".
You will need to download the wget for windows and extract it in a folder called MJautoupdate. Create a batch file called MJupdate.bat and put the commands below in it. If your service is called something other than "magicjack" then change the name at the beginning and end of the script.
Copy this whole MJautoupdate folder into your mjusb folder. Create a scheduled task to run this batch file whenever you want.
Code: Select all
net stop magicjack cd .. attrib -h *.* /s /d md ..\mjusbspbak\ copy *.* ..\mjusbspbak\ Copy upgrade.exe upgrade.old .\MJAutoUpdate\wget.exe -N http://upgrades.magicjack.com/upgrade/upgrade.exe upgrade.exe taskkill /im magicjack.exe /t /f taskkill /im magicjackloader.exe /t taskkill /im magicjacksplash.exe /t reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v cdloader /f net start magicjack
No terminate.bat needed?
I tried this out the step in Post #1 and noticed MJ came back on it's own after running mjupdate.bat. Should I still run the terminate.bat file? Would that terminate MJ?
Files are being deleted
Let me rephrase my Q. So the goal is not to store any upgrade files locally.
adding "rem" to the line "copy upgrade.exe upgrade.old" too care of one file.
Now I don't want any upgrade.exe file locally.
Is the Upgrade.exe required? I thought wget will get this online then copy this locally then run it. I noticed if I remove the existing Upgrade.exe, it won't upgrade.
adding "rem" to the line "copy upgrade.exe upgrade.old" too care of one file.
Now I don't want any upgrade.exe file locally.
Is the Upgrade.exe required? I thought wget will get this online then copy this locally then run it. I noticed if I remove the existing Upgrade.exe, it won't upgrade.
By deleting or renaming upgrade.exe, you're essentially putting more stress on both magicjack's servers as well as your own bandwidth. Wget is designed to only download a new version, but it needs to see the version on your computer to compare it to. Delete it and it will always download a new version. This would have been bad for everyone.