RafaelWolf.com

Good enough for government work! :p

 

I was looking for an easy way to geo block IP addresses with iptables or some other mechanism on Linux machines.  I got lucky and found a post online of someone looking for the same thing.  Like the majority of my posts it’s either something someone hasn’t figured out or something that isn’t quite right (not that I’m perfect).  I like using /var/ftp as a “working directory” so here are the steps

Step 1:  mkdir /var/ftp/zoneblock

Step 2:  cd /var/ftp/zoneblock

Step 3:  wget http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz

Step 4:  gunzip all-zones.tar.gz

Step 5:  tar -xvf all-zones.tar.gz

* Also look at the “rm -” commands in the file, you’ll want to run those FIRST before running the ipset.sh script

Step 6:  touch ipset.sh

Step 7:  Copy the below code into ipset.sh:  nano ipset.sh

# Update, all new and more automated!

# Remove the US zone, copyright and
# the tar file
# rm -f us.zone
# rm -f Copyrights.txt
# rm -f all-zones.tar.gz
# rm -f MD5SUM

# For each country in our zone directory
# add it to the country block list of
# ipset’s nethash
# for country in $(ls zone/ | grep zone)
for country in $(ls | grep zone)
# while read $country
do ipset -N $country nethash
# for IP in $(cat zone/$country)
for IP in $(cat $country)
do ipset add $country $IP
done
done

# Countries I used, block all but US
#ad,ae,af,ag,ai,al,am,an,ao,ap,ar,as,at,au,aw,ax,az,ba,bb,bd,be,bf,bg,bh,bi,bj,bm,bn,bo,bq,br,bs,bt,bw,by,bz,ca,cd,cf,cg,ch,ci,ck,cl,cm,cn,co,cr,cs,cu,cv,cw,cy,cz,de,dj,dk,dm,do,dz,ec,ee,eg,er,es,et,eu,fi,fj,fm,fo,fr,ga,gb,gd,ge,gf,gg,gh,gi,gl,gm,gn,gp,gq,gr,gt,gu,gw,gy,hk,hn,hr,ht,hu,id,ie,il,im,in,io,iq,ir,is,it,je,jm,jo,jp,ke,kg,kh,ki,km,kn,kp,kr,kw,ky,kz,la,lb,lc,li,lk,lr,ls,lt,lu,lv,ly,ma,mc,md,me,mf,mg,mh,mk,ml,mm,mn,mo,mp,mq,mr,ms,mt,mu,mv,mw,mx,my,mz,na,nc,ne,nf,ng,ni,nl,no,np,nr,nu,nz,om,pa,pe,pf,pg,ph,pk,pl,pm,pr,ps,pt,pw,py,qa,re,ro,rs,ru,rw,sa,sb,sc,sd,se,sg,si,sk,sl,sm,sn,so,sr,ss,st,sv,sx,sy,sz,tc,td,tg,th,tj,tk,tl,tm,tn,to,tr,tt,tv,tw,tz,ua,ug,uk,um

# If you want to list your rules run this command:
# ipset list geoblock
# * Warning, this WILL be a long list :-)
# You might be better off doing:  ipset list geoblock > geoblock_list.txt
# which will export your list into a text file for further review

# If you want to delete your list entirely runt his command:
# ipset destroy geoblock

Step 8:  If “screen” isn’t installed I recommend installing it, for ubuntu:  apt-get install screen, Cent or RedHat:  yum install screen

Step 9:  screen sh ipset.sh

Step 10:  Look at the above notes in the commented sections, notes start with a #, also note that if you COPY the syntax make sure it’s clean and nothing has skipped lines or gotten weird with the syntax on a line loop or line wrap.  Sometimes posting code on a blog doesn’t translate well because of the line wrapping.

You can confirm each country is indeed in the ipset rule respectively by this:  ipset list me.zone   or you could do any *.zone, au.zone, etc, etc.  You should see IP output!  If so they’re added to your ipset blocks!

If you have questions let me know – I worked on this for a solid hour I think…maybe more trying to get the syntax to work!

  

You know, it’s unfortunate but it would seem that Adobe has stopped compiling Adobe Reader for Linux / Unix systems :(

The last version you can get that will install on Linux / Unix is here:  ftp://ftp.adobe.com/pub/adobe/reader/unix/9.x/9.5.4/enu/

Download the .deb package, right click on it then click “Open with Ubuntu Software Centre” and yes, that’s “Centre” not “Center” – that happens to be a difference in spelling between the American English and British English or English from outside of the United States.  In the town next to the one I live in and where I have an office the street is called “West Centre Avenue” but before I noticed that spelling I hadn’t noticed it in Ubuntu even though I use the English version of Ubuntu there’s still that “quirk”…have you noticed it said “Centre”?  :)

Note:  There are other PDF readers like xPDF but I’m partial to Adobe’s Reader

 

This might help someone, I figured it out in a pinch but was baffled at first :)

If you see this error…

Unable to mount location - Ubuntu file sharing error

…when browsing the network on a Windows network, small home network or even just a workgroup with a few machines then what you might need to do is:

  1. Turn off your samba / Windows servers firewall on the serving machine (the one with the files) – drastic but works quickly
  2. Allow file sharing on your servers firwall – you need to use SMB and TCP protocols, the ports needed to be opened are 445 and 139 (preferred)

That will allow clients to “browse” the network and “find” your server and the shares it is offering to hosts / clients.

If this helped, let me know ;)

 

Installing Zentyal Small Business Server with Software RAID

 

I looked around for a decent installation guide for installing Zentyal in a software RAID.  Even the Zentyal WIKI didn’t show much love.  This is perhaps the most thorough how to install Zentual in a software RAID online to date (Feburary 23rd, 2013).  I went through this before but with CentOS but that’s pretty well documented online.  CentOS’s manual installer with LVM is a bit different but similar enough that using the Zentyal wizard brought back the memories.  It has been a LONG time since I did it and I never did put it into production because I didn’t trust the install even though looking back it probably was a solid setup.  That setup was slightly different anyway since it used a mix of hardware RAID1 and Software RAID1 to essentially give me RAID 10 (I think…) but with slightly less performance than an actual RAID10.  I mirrored the physical disks then mirrored them with software on top of that.  Maybe a new name could be Ghetto RAID?  It would have been confusing I’m sure if a disk did go bad probably so I shy’d away from using it in the end.  That system was for myself anyway not for anyone I was doing work for.

A brief overview of RAID if you care:

RAID 0 = No redunancy, disks are essentially put together to extend your storage so two 250 GB RAID0 disks = 500 GB of storage

RAID1 = A disk mirror, you can lose 1 disk and still be OK, you need 2 disks minimum to use it

RAID5 = Has some kind of parity stripe that allows you to lose 1 disk and still be OK, you need 3 disks minimum to use it

RAID10 = Has parity and mirroring to give you redundancy and performance, you need 4 disks minimum to use it

More on RAID here as I’m sure you want to be enlightened.

There are times when you can’t do hardware RAID, like when I bought a commodity server for a client who needed a server on a shoe string!  The server was a $150 dollar OEM Dell Server but it was a special one only their VERY large customers could buy.  I suspect it was from a Google, FaceBook or some other huge client that had Dell specially build a low end server that company could use for their CDN (Content Delivery Network).  It’s weird, it looks like a Dell 1950 for the most part but has an AMI Bios, it only does hardware RAID 0 and 1 and you can slap 3 SATA disks into it.  So then for only a few hundred dollars more we bought 250 gig, Western Digital “Enterprise” SATA drives and they had a solid Zentyal server with software RAID5 and all that Zentyal has to offer with a touch less than 500 GB of storage on their network.  All for well under $500 dollars!  I can do shoe string quite well, the nice thing about it too is it’s a Dell Dude!  Whenever you can go with a decent hardware RAID setup, the software is better in the on board controllers, there are batteries on them I think so in case of a power loss it won’t lose data and is usually a “best practice”

Installing Zentyal in a software RAID:

Lets get started, mostly images here with little comment.  I assume you know how to boot up into the installer.  If not we’re in trouble!  I like using an app to install it on a pen drive and I boot to that since the system I had didn’t have a CD-Rom or DVD drive.

Screens not show are (and what I chose as selections):

Language:  English – English
Country, territory or area:  United Sates
Configure the keyboard:  No
Country of origin for the keyboard:  English (US)
Keyboard layout:  English (US)
Hostname:  zentyal <– Here’s where you can get creative, I like giving interesting cultural God names like Zeus or Apollo (Also known as “The Lads” on Magnum PI) :P
E-mail address:  Don’t put anything, just continue
Username for your account:  Whatever you want to log in with
Choose a password for the new user:  Complex one hopefully!
Re-enter password to verify:  Retype what you just type in!
Configure the clock:  It should detect your time zone properly

Here you DO need to select your physical disk and prep it so you can set it up via the software RAID.  If you don’t, it just won’t work.  You have to do this for each disk you want in the RAID setup.  In my example, I run through it on all 3 disks so keep that in mind as you walk through the tutorial.  It might be redundant but for real noobs or someone looking for a thorough tutorial they’ll appreciate it because the screen results do change.

Here I think I forgot to take some screen shots, it’s confusing a bit when you’ve got 50+ screen shots!  You should have a screen after you prep the disks all with a:

SCSI# with “FREE SPACE” like the above pic on it.

So I should have a pic on it with all 3 of my disks with “FREE SPACE” of 8.6 GB but I’m missing that.

I’m ALSO missing the screen shot where we go up in the list after all the disks are prepped and then we select “Configure Software RAID” which then takes you to the screen shot below!  I guess I’m just not that good!

Hopefully here you understand which software RAID setup you want – in my example I use RAID5 in my VirtualBox setup just for the tutorial.  If you wanted RAID10 you’d be doing the work on all 4 or more disks that you have.

This is a pretty cool feature actually, a lot of hardware RAID setups let you use a “spare” disk, it’s a hot spare…spinning and running.  If you lose a disk one of the spares will take over as though you slapped it in and replaced a disk.  You can then replace the broken disk.  I’m not sure what happens in this scenario with the software RAID setup.  Does the new disk become the spare?  Probably but you might want to test that theory out!

Here, even though I have “Configure software RAID” selected, it’s not what you should do.  This just shows the new “RAID5 device” we made.  I could probably carve that out but I left it for posterity.

Now that we made out “disk” essentially, we bundled 3 disks into 1 disk (RAID5 device #0) we have to make logical volumes we can partition which will then hold the data.  Think of it as this point as all we have now is a blank hard drive.  The “Volume Group” we’re going to make (and you can name it whatever you want I just named it Zentyal) will house the volumes / partitions where our data will live.

At this point we’ve got 1 physical volume (a disk) and 1 group, I like to think of that as basically the same thing even though it probably isn’t.  What we’re going to do now is partition the Volume Group (disk imo) and partition it.  In linux you typically see /boot, /usr, /tmp, /home, and others.  For Zentyal you will be out of luck booting the system without making a /boot volume and a “/” root volume.  Those are the two minimums I’ve found from experience!  The first time I muddled through this I didn’t have a /boot volume and the system wouldn’t boot!

Now that we’ve partitioned out the disk we have to go into each partition and tell it what we want it to be.  In my example all I do is partition the volume in 3 sections, /boot, /swap, and “/” or root.  If you care to you can do the other volumes noted in the Ubuntu tutorials on other sites including the official Ubuntu document page BUT I find it much easier for most of the installs I do to simply have the afore mentioned 3 partitions.

Notice here how we now have:  Out “OS” <- An arbitrary name I used, it’s actually “/”, also swap and boot.

Commit your changes!

…and we have INSTALL!

Now…there are a few more screens I don’t think it necessary to document like are you using a proxy, blah blah blah.  If you got this far just click ok or next next next.  When it asks if you want to install the GRUB boot loader – ahhhhhhhh YEAH!

That’s it.  You’ve now installed Zentyal in a software RAID5 (of if you chose a different one then you’ve installed that too) configuration.

Results once Zentyal finally boots up, you choose your install options, etc, etc, etc.

Please feel free to comment.

Chromium OS Review

 

So I recently touched base with a guy named Liam who blogs about Chromium OS (misunderstood by me as “Chrom OS”, I thought they were one in the same but apparently they’re not).  I emailed him a few things I found after downloading a Virtual Box image he makes available for download.

Some of my observations:

  1. You have to have a GMail account to use the OS although there is some kind of “guest access”, you can’t use that in any real practical way for computing though.
  2. You can’t get to the root file system (I don’t see a way anyway), I did read online somewhere that it needs to be compiled for “file access” or something like that then Liam said you can access it but it’s “read only”, supposedly this is a good feature. (?)
  3. You can’t install anything except from their app store, reminds me of Apple and how you have to hack the OS to let you install a real installable application (by hack I simply mean dumbing down a security setting).  It would be nice if Chromium OS also had that feature, it is a Linux Kernel so…
  4. The VBox Liam provides doesn’t seem to have the VBox additions thus I have no mouse, hence, all my other difficulties and inability to explore the Chromium OS without putting it on a Chromium OS compatible device.  I’ll have to put Chromium OS on a real netbook or other device to fully explore it I guess.  I doubt I will because of all the negatives of the OS.
  5. You have to trust Google with all your data, it’s pushed to their data centers where the Feds can subpoena them for your information or just look at stuff at will if it’s older than 6 months (is that true for docs and other data or just email?).  Sure, you’re probably not doing anything illegal but do you really trust Google or the Feds with your information?  I don’t!
  6. Because you can’t manage your own system at a file level you assume you haven’t been hacked or your device hasn’t been compromised.  When you use the device I guess ignorance is bliss.  There are lots of documented cases of Google Android devices being compromised in a myriad of ways, they’re almost on par with Microsoft!  :-)

Another thing about bloggers (Liam included) is that I’m finding we’re not fully disclosing conflicts of interest.  Liam is an employee of Google (working there now for 3 months at the time of this post – congrats Liam!).  I thought his blog was a bit too positive, it sounded to me like he was cheer leading the product a bit too much.  He’s been working with the Chromium OS now for 3 years.  He confessed the Virtual Box image lacks full functionality but that he got requests for it so he continues making it available for download.  In my opinion if the mouse doesn’t work it’s pointless but it’s his bandwidth I guess.  I bet those downloading assume the mouse works like I did!  Beware, don’t download the Virtual Box image – it doesn’t work :P

The ONLY good thing about the concept and philosophy of the Chromium OS and pushing your data into the cloud is you’re now device agnostic, you can log into another Chrome Book and have your “profile” if you will on any device.  The negatives in my opinion far outweigh the one positive.

I have security concerns, where is the cache (your local “offline” copy?).  Can another user read it from another profile?  Can I boot into another OS on a pen drive (with Linux for example) and access the profile?  I did fire up a live distribution and poked around a bit but didn’t have much there since I couldn’t get the mouse working in the Virtual Box image thus I never offline cached any data to the image.  I was able to navigate the file system though, interesting layout.  I sudo’d to root and could gain access to every folder.  Seems like 3 disks, OEM, ROOT-A and something else, typical Linux file system layout really.  What happens if the device is hacked like millions of Android phones were and are still today due to malware (yes, malware web apps).  Just search online for “android malware web apps”.   I can’t do anything about it because I have to “trust” Google to fix it, have no access to the file system and I then expose all my data to whomever now owns my device.

The Chromebook devices are CHEAP!  By cheap I mean inexpensive BUT you pay a price.  The price of lost privacy, even if there isn’t a “real person” looking at your data.  It’s the price of becoming a statistic.  They know your age, race, illnesses, where you live, what you look at online thus what you’re intrests are who you be with what numbers to dial (Biggie refferene :P).  Wake up people, GMail, GDrive, etc is not “free”, Google uses that data and sells advertising or your stats to various buyers.

Digitally you are your data.  I’d rather pay more to Google for the stuff I use if I could be black listed from becoming a statistic.  If my data was private and mine but alas, I don’t think that option exists.  You have to hand over your data and your computing soul.

I’m personally avoiding Chromium OS and cloud anything at the moment until I can guarantee my data is my data and it’s hands off from becoming a statistic.  Unfortunately most people aren’t that technical and don’t have those options so they’ll all get pushed like sheep to the cloud :-(

 

 

 

 

  

Just a quick note about error 0×80070002 if you’re using server 2012 when trying to access a DFS share.  My clients configuration is currently this, we’re working through a few “quirks” that have cropped up when rolling this out.  For the most part things have gone well but if you can’t access your shares you’re in trouble.  It wasn’t every client either, just one in particular and I didn’t want this to spread.  I also saw some slow downs on a few other clients so maybe this issue was going to creep.  Not good!

So, the long and short of it is this:

Their server setup was – 2 Windows Server 2003 Servers doing DNS, AD (we moved DNS, AD and file shares to the new 2012 servers).  2 Windows Server 2012 servers now doing DNS, AD, DFSr and file sharing.

DFS setup, you could access them this way:

\\domain\dfsfolder\sharedfolders

\\server1\dfsfolder\sharedfolders

\\server2\dfsfolder\sharedfolders

So for their purposes one server was at location A and the other at location B.  This allowed them to have the same “shared drives” at each location.  You simply adjust the logon script for said user at location A or B to point to their locations local server and DFS shared folder.

One particular client was getting this error though: “Windows cannont access \\server1\dfsfolder\sharedfolder”  Error code: 0×80004005 Unspecified error.

What I figured out (and this must be some kind of DNS error / issue because we’re no longer using WINS) is you have to use the FQDN (Fully Qualified Domain Name) for this to work.

So try:

\\server1.yourdomain.local\dfsfolder\sharedfolders

It should come right up!  I had at one point 4 DNS servers (the 2 server 2003 and 2 server 2012′s) and we’re migrating to only 2 and decommissioning the server 2003 servers.  The 2003 server DO in fact do WINS.  I suspect, depending on who you got your answer from when you tried looking for \\server1\…you’d get a different answer, you wouldn’t get the answer that makes this magic work from the server 2012 servers unless you use the FQDN because we’re not using WINS.  It’s definitely a “name resolution” issue.  I haven’t figured it out fully yet and I don’t have the time to really dig into it but that’s the “fix”.  Use an FQDN to access the share ;-)

 

 

  

Quick note here on a Dokuwiki error I encountered.

I was getting and “undefined function()” error on line 13 in this file when upgrading Dokuwiki, it was a bit irritating because nobody else had the fix BUT I figured I’d give commenting out the line a shot ;-)

Those lines are in the file:  /var/www/doku/lib/tpl/dokuwiki/main.php

13 $hasSidebar = page_findnearest($conf['sidebar']);
14 $showSidebar = $hasSidebar && ($ACT==’show’);

So, nano main.php

Then change your file to this:

“/** $hasSidebar = page_findnearest($conf['sidebar']);
$showSidebar = $hasSidebar && ($ACT==’show’); */”

The /** and */ will comment out in this example <– the “and” so doing that in the main.php gets rid of the undefined function because we take the function out of their code :-)

Not sure what effect this might have on the functionality of the wiki BUT it seems OK, I’m not on the Dokuwiki team, I’m only hack :P

Good luck and definitely let me know if this helped you out.

Dokuwiki version: 2012-10-13

BOOTMGR image is corrupt

 

I bumped into a laptop that; after a hard disk check to see if the hard disk was bad using the Ultimate Boot CD (aka UBCD – a great tool by the way!).  I suspect the hard disk had bad sectors on it (as all hard drives do) but that some of the OS files were sitting on these sectors.  Thus, the system was having problems and after the diagnostics were run, I tried to boot the system and got this error:

BOOTMGR image is corrupt

or

File: \windows\system32\winload.exe status: 0xc0000221

This link had most of the fix although, watch out because if your OS isn’t on “c:” then it won’t work, THUS MY POST – to help those of you who aren’t too technical to figure it out ;-)

Dinesh was a big help though!

Link:  http://www.sevenforums.com/tutorials/104341-bootmgr-missing-fix.html

Note, look at what the wizard says your OS drive is, mine on the system I was working on was D: thus the commands you need to run in the tutorial aren’t going to start with “c:\…”, you do a “d:\…”.

Dinesh then said to change directory (cd) to your c:\boot directory.  The boot directory was MISSING on the system I was working on…thus, it won’t boot :-)

Do a:

mkdir d:\boot

If it exists you’ll simply get an error that it exists but again, mine didn’t.

Then run his commands after you cd into it:

bootrec /FixMbr
bootrec /FixBoot
bootrec /RebuildBcd

Now, one MORE command for you IF that doesn't work ;-)

bcdboot D:\Windows
* Hey!  Remember!  Your boot drive might not be "D:" like mine, just a friendly reminder.

When I got further into the process the first 3 commands from Dinesh moved me forward but then the system got to the second error about a missing or corrupt winload.exe file.

Once you get Windows back up you might STILL have some errors, you might then need to open a command prompt and type in "sfc /scannow" to fix any operating system level files.

Another reboot and all should be well.  Maybe do a disk check on it by right clicking the hard drive > properties > tools (I think it is) and then do a disk check.

Notes on upgrading VMWare ESXi 4.x to 5.x

 

ESX is no longer being developed from what I read on VMWare’s site, who cares right?  I was using ESXi so I got lucky ;-).  Anyway, if you don’t have any fancy plugins or their Data Management Suite to mange BILLIONS of servers, VMotion from here to the nearest quasar and only dropping one ping or a total HA server cluster that won’t go down if you shot it with an elephant gun THEN all you need to do is:

1 – Download the new version of ESXi

2 – Pop the disk in, reboot your server (make sure your VM’s are shut off)

3 – Follow the prompts, it pretty much detects your disks and file system.  Do an “upgrade” and leave your files alone, I think it said something about keeping your file system (VMFS) in tact.

4 – Next > then sweat a little bit, bit your nails and eventually you’ll see a “success” message.  Then pop the disk out and reboot again.

* I sweated over this too!

One gotcha for me was when it came up my thinly provisioned disks were now “thick” thus I ran out of real estate since in a way I “over promised” disk sizes in my VM’s knowing I probably wouldn’t really need 80 gig for a Linux machine.  BE CAREFUL not to make the same mistake.  IF you find your disks are thick and you want to put things back and make all right with the world you can convert the thick one’s into thin by this command below…thanks BTW to TooMeeK who had the correct command syntax for me.  I was a bit stumped until he/she showed me the way!

1 – You need to go into the config options on your VMWare server and enable SSH.

2 – SSH into the server, I assume you know how to do this since it’s Linux and if now well go look online and come back when you’re in :P

3 – Migrate to your VM storage area.  This might take some poking around.  The server I was working on was in:

/vmfs/volumes/4c5d465f-c17a75db-572b-001c23c9ca24/MyVMHere/

…so, if you cd /, then cd vmfs/volumes, then do an “ls -la” or just “ls” you might see a few folders with LONG numbers.  One of these (ore more really, I only had one) are where your VM’s are stored!

4 – Now,  you need to “cd” to your VM folder for your VM’s that you want to shrink / convert from thick to thin.

5 – Run this command and wait – note that it DOES in fact take a hit on your server performance, I think it’s doing some serious disk i/o:  vmkfstools -i old_vms_name.vmdk -d thin new_vms_name.vmdk

6 – This is where I got a but stumped on number 5 – I kept looking at the actual VMDK file for the guest OS, really what I wanted was the name of the tiny VMDK file that DEFINES what the bigger thick VMDK is!  That’s what tells vmkfstools what the heck it is and HOW to convert it :-)

Special thanks to this site and TooMeeK for the help on this:  Tutorial and TooMeeK’s comment was the fix!

7 – Then – when done, go into your VCenter, delete the current OS disk (it’s ok you’re not really “deleting” it :P) and then add a new disk, go find your VM’s folder on the store and inside that folder there’s your newly converted THIN disk!  Add it, button it up with however many next’s and OK’s you have.  Then go start your VM.  Magic!

I was very cautious about everything and I even backed up my VM’s with the “gzip” command.  “gzip yourvm.vmdk”.  It can take a LONG time depending on your disk config.  For me, I had an 80 gig VM shrink down to just a few gig zipped, then you can “download” it from the VCenter app you use to manage your server.  This is a technique to manually back up your raw images.  It’s tedious to say the least but at least you know you have a solid backup before you try and take VMWare server from 4.0 to 5.0 or 5.1.  Sometimes caution and tediousness pay off!

Microsoft Silverlight patching script

 

Here’s a handy little M$ $ilverlight updater script you can use.  I had a few clients on version 4, then one got prompted for a site they use to “Install Silverlight”.  If they didn’t they couldn’t use the site, odd thing was they already had it installed!  Apparently, the real problem is they wanted a more current version.  Understandable I guess.  Here’s a system startup script you can apply via Group Policy to machines as they startup.  If it doesn’t find version 5 then it installs it, if it does find version 5 it ends.

I won’t explain too much, I assume you can modify the network paths to your environment and don’t need much hand holding :P

Download link for Silverlight version 5 <– There

Remember too you need the “filever.exe” file to check file versions via the command line.  Search my site or the InternetS for the download.

Put the below in a batch file (filename.bat).

@echo off
:: SilverLight v5 installer

:: Note that a value of 0 = true, value of 1 = false

echo Checking to see if you have Silverlight installed…
if exist “%ProgramFiles(x86)%\Microsoft Silverlight” goto filever
if exist “%ProgramFiles%\Microsoft Silverlight” goto filever
goto end

:filever
:: V5 checker
“\\yourserver\yourshare\filever.exe” “%ProgramFiles(x86)%\Microsoft Silverlight\sllauncher.exe” | findstr /C:”5.”
“\\yourserver\yourshare\filever.exe” “%ProgramFiles%\Microsoft Silverlight\sllauncher.exe” | findstr /C:”5.”
echo Error value is %errorlevel%
if %errorlevel% EQU 0 goto end

:: x86
“\\yourserver\yourshare\filever.exe” “%ProgramFiles(x86)%\Microsoft Silverlight\sllauncher.exe” | findstr /C:”4.0″
echo Error value is %errorlevel%
if %errorlevel% EQU 0 goto end
echo Upgrading Silverlight…
\\yourserver\yourshare\silverlight /q
goto end

“\\yourserver\yourshare\filever.exe” “%ProgramFiles(x86)%\Microsoft Silverlight\sllauncher.exe” | findstr /C:”4.1″
echo Error value is %errorlevel%
if %errorlevel% EQU 0 goto end
echo Upgrading Silverlight…
\\yourserver\yourshare\silverlight /q
goto end

:: x64
“\\yourserver\yourshare\filever.exe” “%ProgramFiles%\Microsoft Silverlight\sllauncher.exe” | findstr /C:”4.0″
echo Error value is %errorlevel%
if %errorlevel% EQU 0 goto end
echo Upgrading Silverlight…
\\yourserver\yourshare\silverlight /q
goto end

“\\yourserver\yourshare\filever.exe” “%ProgramFiles%\Microsoft Silverlight\sllauncher.exe” | findstr /C:”4.1″
echo Error value is %errorlevel%
if %errorlevel% EQU 0 goto end
echo Upgrading Silverlight…
\\yourserver\yourshare\silverlight /q
goto end

:end
echo The glass is either half empty
echo or half full :P

Note that the “silverlight.exe /q” is a quite install, the “/qu” switch is a “quiet uninstall” so technically to be cleaner you’d want to “uninstall” your old version then install the new version but it’s only SilverLight so who cares?  :P  For a slicker script you could also do a mashup of another script I have that detects architecture which would then negate the need to check both the Program Files AND Program Files (x86) folders but I didn’t do it like that because I tweaked an existing script and didn’t want or need to reinvent the wheel.

“Technically” you probably do want to do the quiet uninstall of the old version just to keep consistency and to keep a tidy group of hosts but…it’s a free world…I think.

Ideally, to be completely strict you’d detect architecture (32 bit or 64 bit), then check version, then uninstall if necessary, then call your installer for the latest version.

5 visitors online now
5 guests, 0 members
Max visitors today: 8 at 08:30 am UTC
This month: 16 at 05-14-2013 06:54 pm UTC
This year: 20 at 04-24-2013 02:28 am UTC
All time: 36 at 08-30-2010 02:32 am UTC