Archive for the ‘Windows’ Category

PowerShell SharePoint Site Collection Backup Script March 14th, 2010

Mike

I have been meaning to write a script in PowerShell to do SharePoint Site Collection backups for a while but not got round to it. I did do a quick and functional one at the tail end of last year, but it wasn't particularly elegant. This script I am much happier with: it will backup all Site Collections at the specified Web Application and place them at the given location in a folder constructed from the day's date. It also writes to a log file and can clean up folders containing backups that are older than a predetermined number of days.

Simply copy the script below and save it to a .ps1 file of your choice. Please retain my comments at the top and, as always, use at your own risk! The deletion portion is quite destructive :) . You may also have to set your Execution Policy to a less strict setting, such as RemoteSigned, e.g.:


Set-ExecutionPolicy RemoteSigned

I have tested the script with Microsoft Office SharePoint Server 2007 SP2 and Windows SharePoint Services 3.0 SP2 running on Windows Server 2003 R2 SP2 (PowerShell 1.0). It should work fine for MOSS and WSS running on different Windows Server operating systems.

Here is the script:

# SharePoint Site Collection Backup Script
# Author: Michael Cox
# Version: 1.0
# Date: March 2010
# Contact: http://www.betteritsolutions.co.uk/
# Use at own risk, please retain these comments

# Create alias for STSADM
Set-Alias -Name exeStsadm -Value ($Env:CommonProgramFiles + "\Microsoft Shared\Web Server Extensions\12\BIN\stsadm.exe") -Option Constant
# Specify maximum age in days for backup files
New-Variable -Name maxFileAge -Value 14 -Option Constant
# Get todays date, formatting as yyyyMMdd e.g. 20100224
New-Variable -Name todaysDate -Value (Get-Date -Format yyyyMMdd) -Option Constant
# Specify backup location and set log file location, folder must exist and be writable by account running script
New-Variable -Name backupLoc  -Value "S:\Backups" -Option Constant
New-Variable -Name logFileLoc -Value "$backupLoc\site_collection_backups.log" -Option Constant
# Specify Web Application
New-Variable -Name webApplication -Value "http://mossintranet/" -Option Constant

# Change to backup location and create folder, suppressing notification
Set-Location $backupLoc
New-Item $todaysDate -type directory | Out-Null
Set-Location $todaysDate

# Record backup start
Out-File -FilePath $logFileLoc -Append -InputObject $("Backup started at: " + (Get-Date -Format HH:mm` dd/MM/yyyy) + "`n")

# Enumerate Site Collections within chosen Web Application and store in a variable
[xml]$sitesXml = exeStsadm -o enumsites -url $webApplication

# Enumerates each site collection and performes an stsadm sitecollection backup against each site
$sitesXml.Sites.Site | ForEach-Object -Process {$backupFile = $_.Url.Replace('http://','').Replace('/','_') + ".bak"; exeStsadm -o backup -url $_.Url -filename $backupFile; Write-Host "Finished writing: $backupFile"; Out-File -FilePath $logFileLoc -Append -InputObject "Finished writing: $backupFile"}

# Remove folders that are older than the maxFileAge value
Set-Location $backupLoc
$tooOld = (Get-Date).addDays(-$maxFileAge)
Get-ChildItem | Where-Object {$_.PSIsContainer -and ($_.lastWriteTime -le $tooOld)} | ForEach-Object -Process {Remove-Item $_ -force -recurse; Write-Host "Folder $_ was deleted."; Out-File -FilePath $logFileLoc -Append -InputObject "Folder $_ was deleted."}

# Record backup end
Out-File -FilePath $logFileLoc -Append -InputObject $("`n" + "Backup ended at: " + (Get-Date -Format HH:mm` dd/MM/yyyy) + "`n")

Here is a screenshot of files created following a backup of a Web Application with two Site Collections and also the contents of the log file:

Screenshot after running script

Screenshot after running script

Please let me know if this is useful and also feel free to make suggestions for improvements or bug fixes, if you find any.

Continue reading...


 

Windows XP AHCI Mode Install Hangs January 10th, 2010

Mike

Recently I decided to reinstall Windows XP Pro on my home desktop. Yes, I know, Windows 7 is out and far superior but I have some music software that only runs well on XP as well as having already paid for XP… just bear with me!

I won't go overboard, but here are the relevant technical details: ASUS P5B Deluxe motherboard with Intel ICH8R onboard SATA controller and 3 x 250GB SATA HDDs. I used to have two of these in RAID 0 (yes, I have backups) but I decided that the performance benefits vs. just sensibly placing things on different drives wasn't worth the extra risk. So, for my reinstall I would be moving from RAID mode in the BIOS to AHCI mode.

I backed up everything, flashed the BIOS with the latest version (good time to do it when I am reinstalling anyway), set all my settings and flipped the ICH8R to AHCI mode. As I expected, my old XP install no longer booted as it was configured for RAID mode with the appropriate driver. Linux coped fine, though :) . I popped in the XP Pro SP2 CD, hit a key when prompted and watched the message: Setup is inspecting your computer's hardware configuration. After that, nothing. No chance to hit F6 or anything. Just a black screen. I even left it for ages in case it would finally realise it couldn't read the disks yet. No joy. Hmmm.

Basically, there seemed to be some issue with the fact that the setup CD could understand that there was an operating system installed but not properly read it and it was getting stuck. OK, no bother, whack in a Linux live CD and nuke the disks. In case you are interested, I like using badblocks in write mode but anything that destroys the partitions would do I expect.

Right, attempt number 2 (well actually a much higher number, but if you are reading this you don't need to follow my mistakes!): this time I get to the F6 prompt, add the AHCI driver from a floppy (drive hanging out of the side of the PC – why would I have a floppy drive on a modern PC?) and Windows sees the disks. Great! Actually, no. This time it sees 1 x 250GB disk and a 500GB disk that it cannot access (the old RAID array). Having selected AHCI in the BIOS and the AHCI driver this did surprise me. No problem, back in the BIOS and enable RAID then into the RAID BIOS and delete the array. Back in the BIOS again, enable AHCI.

Attempt number 3 and we have success! 3 x 250GB disks detected (after using the F6 option to add the driver) and I install Windows XP.

So in summary, if you want to reinstall Windows XP and go from one SATA controller mode to another, my tips would be:

  • Break any RAID arrays in the RAID BIOS
  • Delete any existing partitions on your disks
  • Make the BIOS changes you require
  • Boot to the setup CD and slipstream the correct driver

Simple when you know how! As an aside, I was installing from a SATA DVD drive and that caused no issues (I saw some people report that this is a problem). I know this wasn't part of the problem because I even had another 'donor' machine next to my desktop at one point so I could try installing from an IDE optical drive…

Continue reading...


 

Install VMware Tools on Windows Server 2008 R2 Core December 3rd, 2009

Mike

I was surprised to discover that it's very easy to install the VMware Tools on Windows Server 2008 R2 Core today. Simply select the VM in VMware Infrastructure Web Access (assuming you are using VMware Server 2, if not use the appropriate interface) and click the Install VMware Tools link. The iso won't autorun, but all you have to do is change to the virtual CD–ROM drive within the VM (probably D:) and run:


msiexec /i "VMware Tools64.msi"

VMware Tools Installed

VMware Tools Installed

Continue reading...


 

Search Server Express 2008 Requires SP2 on Windows Server 2008 R2 November 30th, 2009

Mike

I recently installed Windows SharePoint Services (WSS) 3.0 with SP2 on Windows Server 2008 R2, with the intention of adding Search Server Express 2008 for enterprise search functionality. However, when I tried to run the Search Server install I was greeted with the following unfriendly message:

Program Compatibility Assistant

Program Compatibility Assistant

After some digging around and Googling, I discovered that Search Server wouldn’t install on Server 2008 R2 without Service Pack 2. Unfortunately, it doesn't appear possible (at this time) to download it with SP2 so what do you do? I did a little experimenting and found out that you can slipstream the The 2007 Microsoft Office Servers Service Pack 2 (SP2) into the install. Note that the download page actually specifies the service pack will update Search Server. Here's how to slipstream it:

  1. Open a command prompt, navigate to the location of the file SearchServerExpress.exe and run SearchServerExpress.exe /extract:SearchServer. This extracts (but doesn't install) Search Server Express to the folder SearchServer.
  2. Download the 2007 Microsoft Office Servers Service Pack 2 to the same location as the install file for Search Server Express.
  3. From the same command window, run officeserver2007sp2-kb953334-x64-fullfile-en-us.exe /extract:SearchServer\Updates (you will have downloaded the 64–bit version as Windows Server 2008 R2 is 64–bit only). This extracts the service pack files into the Updates folder of the Search Server install.
  4. Run setup.exe from within the SearchServer folder

 

You should find that the Search Server install now runs happily without complaining and pauses for a period of time to apply updates towards the end of the process.

Happy searching!

Continue reading...


 

Install PowerShell on Windows Server 2008 R2 Core November 18th, 2009

Mike

Today I installed Windows Server 2008 R2 Standard Core, expecting to be presented with PowerShell. Wrong. I was presented with good old cmd.exe. It took me a while to find this information, so I thought I'd blog it here. To install PowerShell, you need to run the following commands:


DISM /Online /Enable-Feature /FeatureName:NetFx2–ServerCore
DISM /Online /Enable-Feature /FeatureName:MicrosoftWindowsPowerShell

Now you can launch powershell.exe from C:\Windows\System32\WindowsPowerShell\v1.0. Although the path would suggest PowerShell 1.0, a quick Get-Host indicates PowerShell 2.0:

Get-Host output

Get-Host output

A little more about DISM, for those that are interested. DISM is the "Deployment Image Servicing and Management tool" and can be used to perform various configuration tasks on offline or running images. Hence the /Online switch is used to tell DISM it must target the running operating system. The following command will list all features and their status (suggest you pipe it through more):


DISM /Online /Get-Features | more

Note that PowerShell requires .NET Framework 2.0, hence the first DISM command.

Thanks to Vincent Hu for his post on TechNet, which I finally found. There is a slight mistake, though, as there should be no space between /FeatureName: and the feature you want to install.

Continue reading...


 

Working With Kerberos Authentication Part 4 – Shared Services Provider November 2nd, 2009

Mike

In this part I will talk about configuring your SSP to use Kerberos.

The next step (if required in your environment) is to configure Kerberos for the Shared Services Provider. This includes root and virtual directory level Shared Services. A prerequisite for this step is the SharePoint Infrastructure Update (which was released post SP1).

Configuring the SSP Web Application is very similar to a normal Web Application, so we'll keep it brief. Assume we have the SSP's Web Application running on port 1234 not using a host header. Then, the commands to map the SPNs are as follows:


setspn –A HTTP/servername:1234 yourdomain\UserRunningAppPool
setspn –A HTTP/servername.yourdomain.com:1234 yourdomain\UserRunningAppPool

Turn on Kerberos authentication for the SSP Web Application as described for the content Web Application (previous post) and perform the same test, ensuring you see a successful Kerberos logon event in the Security log on the server hosting the SSP.

In order to fully configure Kerberos for the SSP and Excel Calculation Services, further SPNs must be set using a new, custom format. There are also STSADM commands to run and a change to be made to the registry of each server.

Map the SPNs with the following commands:


setspn –A MSSP/servername:56737/SSPName yourdomain\SSPServiceAccount
setspn –A MSSP/servername:56738/SSPName yourdomain\SSPServiceAccount

SSPName is simply the name you gave your SSP. It cannot contain extended characters so be sure to name your SSP with care at install time! You must also generate a pair of SPNs for each server in your farm. I.e. in a standard medium server farm (2 WFEs and 1 App server), you will set 6 SPNs, 2 for each server name.

Now run the necessary STSADM commands on a server in the farm:


stsadm –o setsharedwebserviceauthn –negotiate
stsadm –o set-ecssecurity –accessmodel delegation –ssp
stsadm –o execadmsvcjobs

In order, this sets the Shared Services Web Service to use Kerberos, Excel Calculation Services to use delegation and then forces the timer jobs to run immediately.

Lastly, each SharePoint Server will need a registry key adding to allow it to use the new custom format SPNs.

  1. Run regedit
  2. Go to the registry path HKLM\Software\Microsoft\Office Server\12.0 and right click 12.0 >> New >> DWORD Value
  3. For Name type in KerberosSpnFormat and change the value from 0 (default) to 1.

After this step, you must reboot your server.

There is some additional configuration required within Component Services. In order to prevent the occurrence of DCOM errors, all of your Application Pool service accounts should have Local Launch and Local Activation permissions on the IIS WAMREG Admin Service object, most easily achieved by giving the permissions to the local groups: WSS_WPG and WSS_ADMIN_WPG (this ensures that newly created Application Pool service accounts are granted the permissions, since SharePoint adds them to this group). This is well documented elsewhere.

However, there's also a modification to be made to the servers in the farm within Component Services. Click on Start > Administrative Tools > Component Services. Expand Component Services > Computers, right click on My Computer and select Properties. On the Default Properties tab, change the Default Impersonation Level to Delegate and click on OK.

My Computer Properties

My Computer Properties

References

There are a huge number of references for configuring Kerberos. Here is a useful selection:

That concludes my guide to Kerberos for SharePoint. I hope you have found it useful and if you have any queries, please send them to me.

Continue reading...


 

Working With Kerberos Authentication Part 3 – SharePoint Web Apps October 24th, 2009

Mike

This part of the four part series will look at configuring Kerberos on SharePoint Web Applications.

The first thing we need to do is to map some SPNs (again) and the SPNs themselves depend on whether you are using CNAMEs or A Records to resolve your web sites. If you are using CNAMEs, whose targets are servers with associated A Records, you construct the SPN using the CNAME's target (i.e. the hostname in the A Record). In the case of an A Record, it's much simpler; just use the hostname in the A Record. If you're unsure and don't have access to DNS (for whatever reason) then ping the DNS name and see if it resolves directly to an IP address or tells you it's pinging another address. The former result indicates an A Record is in use, the latter indicates a CNAME.

In the case of CNAMEs, it'll often be the case that the target is a machine which will mean constructing SPNs based on that computer's name. There's a further complication in that the same SPN cannot be assigned to more than one account so if you have a collection of CNAMEs for different Web Applications all resolving to the same A Record, each Web Application must use the same domain account for its Application Pool Identity to maintain a unique mapping of SPNs (this will become clear below).

As an example, I am creating SPNs for a site served on the host header kerbtest on port 80 with an appropriate A Record associated with it. The fully qualified SPN is optional (depending on whether the site is ever accessed using the FQDN), but I would always include it.


setspn –A HTTP/kerbtest yourdomain\UserRunningAppPool
setspn –A HTTP/kerbtest.yourdomain.com yourdomain\UserRunningAppPool

Note that HTTP in this case refers to the HTTP service, NOT the protocol. A common mistake is to mistype the above and start them with HTTP://, which is incorrect.

If your domain functional level is Windows Server 2003 or later, you will need to make some changes on the Delegation tab of the user account running the Application Pool. In Active Directory Users and Computers, locate the user object, right click on it and select Properties. Click on the Delegation tab and change the setting to either Trust this user for delegation to any service (Kerberos only) or Trust this user for delegation to specified services only.

Delegation Tab

Delegation Tab

Some guides will discuss enabling delegation for the computer account in Active Directory as well, but this is only necessary if the service process is running under the Local System account, which is not the case here.

If constrained delegation (the more secure and, therefore, recommended option) is required, I would suggest making sure everything works with unconstrained delegation first, before pressing on with constrained.

Kerberos can be enabled either at Web Application creation time, or later. I would usually implement it later, and make sure that the Web Application functions correctly with NTLM first.

To change the Authentication Provider to Kerberos, from SharePoint Central Administration (SCA), click on Application Management. Click on Authentication providers under Application Security. Make sure that the correct Web Application is selected and then click on the Zone that you wish to move to Kerberos. I will click on Default. The only change you should need to make is to alter the IIS Authentication Settings by changing the radio button from NTLM to Negotiate (Kerberos). Click OK when the warning dialogue box appears and then scroll to the bottom of the page and click on Save.

Edit Authentication

Edit Authentication

From another machine on the domain (not one of the SharePoint web front end servers), browse to the Web Application. On the Web Server that you hit you should see an event with ID of 540 in the Security log, containing the following kind of information:


Event Type: Success Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 540
Date: 09/07/2009
Time: 14:10:52
User: domain\user
Computer:
Description:
Successful Network Logon:
User Name:
Domain:
Logon ID: (0x0,0x2D996B)
Logon Type: 3
Logon Process: Kerberos
Authentication Package: Kerberos
Workstation Name:
Logon GUID: {5dea6995-63c8-8ab0-0b1d-e80325461c16}
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: 10.11.12.2
Source Port: 1301

Again, computer, domain and user names have been deliberately removed.

This concludes configuration of Kerberos for a SharePoint Content Web Application. In the final part I will describe how to switch the Shared Services Provider to Kerberos and also add a list of useful references for further reading.

Continue reading...


 

Working With Kerberos Authentication Part 2 – Configuring (SQL) August 31st, 2009

Mike

What follows are the instructions for configuring Kerberos for various aspects of SQL (this part) and SharePoint (Part 3, coming soon). This is not necessarily a hard and fast set of instructions but a collection of steps known to prove working results for Microsoft Office SharePoint Server (MOSS) 2007 with SP1 and the Infrastructure Update running on Windows Server 2003 R2 with SP2 and connected to a Microsoft SQL Server 2005 Database Engine. Configuration may be slightly different for Windows Server 2008 (and therefore later versions of IIS than 6.0). Note that the infrastructure update for MOSS is necessary if you require all aspects of your Shared Services Provider (SSP) to use Kerberos. These instructions should also be fine if you are running MOSS SP2.

Enabling Kerberos for the SQL Server Database Engine

To enable Kerberos for SQL Server, it is simply a case of mapping the correct SPNs to Active Directory user accounts. Up to four commands should be run:


setspn –A MSSQLSvc/sqlserver yourdomain\SQLServerServiceAccount
setspn –A MSSQLSvc/sqlserver.yourdomain.com yourdomain\SQLServerServiceAccount
setspn –A MSSQLSvc/sqlserver:1433 yourdomain\SQLServerServiceAccount
setspn –A MSSQLSvc/sqlserver.yourdomain.com:1433 yourdomain\SQLServerServiceAccount

This is for a default instance on port 1433. If the port number has been manually changed or you are using a non-default instance then only two SPNs are required but you must use the two commands above containing the port number and substitute your non–default port number. Also ensure that the non–default instance is properly configured to use a fixed port number.

Two less SPNs are required in this case because clients can no longer connect by simply using the computer name, they must specify the port number so any SPNs without port numbers would simply never be passed.

We can check that Kerberos is now working by connecting to SQL using the Management Studio from another machine on the same domain. Open the Management Studio, connect to the Database Engine and look in the Security log on the SQL Server. You should see a 540 success event containing the following kind of information:


Event Type: Success Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 540
Date: 09/07/2009
Time: 12:17:37
User: DOMAIN\UserName
Computer:
Description:
Successful Network Logon:
User Name:
Domain:
Logon ID: (0x0,0x3FF14)
Logon Type: 3
Logon Process: Kerberos
Authentication Package: Kerberos
Workstation Name:
Logon GUID: {cc8d6921-4c0d-e68c-8b1b-ba2fcdf4836f}
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: 10.11.12.3
Source Port: 1150

Note that user, domain and computer names have been deliberately removed.

This is all that is required for the SQL Database Engine to use Kerberos. It always prefers to use Kerberos by default but if you manually choose the accounts used to run your services (which is usual) then you have to add the SPNs to Active Directory yourself for it to work. According to MSDN: For Win32 services, a service installer specifies the logon account when an instance of the service is installed. The installer then composes the SPNs and writes them as a property of the account object in Active Directory Domain Services. If the logon account of a service instance changes, the SPNs must be re-registered under the new account.

Using Kerberos with other SQL Components

In addition, if you wish to connect to other SQL components using Kerberos (such as Analysis Services) then you will require further SPNs. The commands for adding SPNs for use with Analysis Services are as follows:


setspn –A MSOLAPSvc.3/sqlserver:instance yourdomain\SQLServerAnalysisServicesServiceAccount
setspn –A MSOLAPSvc.3/sqlserver.yourdomain.com:instance yourdomain\SQLServerAnalysisServicesServiceAccount

Note that this is a little different to the SPNs for the Database Engine because, rather than a port number, you specify the instance name (if non–default, otherwise leave blank). SQL Server Analysis Services can only operate as a named instance in SQL Server 2005 (it is not supported in SQL Server 2000).

In the next part, I'll move on to talking about configuring Kerberos for SharePoint.

Continue reading...


 

Working With Kerberos Authentication Part 1 – Introduction July 23rd, 2009

Mike

I've had a few encounters with Kerberos so, as a result, I decided to collect what I have learnt together in a series of blog posts. Primarily my concern is with regards to enabling Kerberos Authentication for SharePoint, but I will add some general information, too.

Enabling Kerberos offers a few advantages over NTLM, it:

  • Is less susceptible to replay attacks because it includes a timestamp of when the network traffic was sent
  • Allows verification of servers through the use of Service Principal Names (SPNs)
  • Reduces authentication traffic because authentication is valid until the tickets expire (or are manually purged)
  • Allows authentication over multiple hops (via the use of delegation).

The last point is frequently the driving force in enabling Kerberos for SharePoint, although reduced authentication traffic and increased performance are also often cited. An example of where we might need authentication over multiple hops would be where we need to authenticate with a SharePoint Web Application, our credentials have to be passed on to a web service and this web service has to pass our credentials to SQL to retrieve data from a database. This is only possible if Kerberos is enabled and the intermediate accounts are trusted for delegation in Active Directory.

Concepts

There are some concepts key to Kerberos which are worth understanding. This is a very basic level understanding of them but hopefully will provide some insight.

What is a Service Principal Name?

An SPN is a string constructed using an arbitrary text name for a service, the computer name that the service is running on and the port. This then appears in the following format:

ServiceName/Computer:Port

An example would be MSSQLSvc/sqlserver01:1433

It is used to allow a client to uniquely identify an instance of a service.

To enable Kerberos we need to configure a mapping in Active Directory between SPNs and the account that the service is supposed to be running under. To do that, we either use ADSIEDIT or SETSPN (found in the Windows Server Support Tools or downloadable from Microsoft). You must at least be a domain administrator to perform these updates.

SETSPN

SETSPN is a command–line tool and has 3 switches that we're interested in:

–A to add an arbitrary SPN
–D to delete an arbitrary SPN
–L to list registered SPNs

The syntax we'll use is as follows:

setspn –A service/computer:port domain\user
setspn –D service/computer:port domain\user
setspn –L domain\user

Computer may be the NetBIOS name, Fully Qualified Domain Name (FQDN) or another DNS name – more about this later.

How Kerberos Works (very briefly)

Kerberos is an authentication service developed at MIT. The idea behind Kerberos is that both the user and service have a shared key and this is used to encrypt and decrypt something freshly created (for example a timestamp). If the wrong key is used at either end, decryption is not possible and authentication fails. In practise, what occurs is much more complicated, but this is the very basic idea.

When using Kerberos in a Microsoft environment, broadly speaking, the following occurs. A Kerberos authentication server will grant a ticket in a response to a client computer authentication request, as long as the request contains valid user credentials and a valid SPN (see above). This ticket can be used to access network resources. For the lifetime of the ticket (by default, it is 600 minutes, i.e. 10 hours) a new ticket does not have to be issued and this is how authentication traffic is reduced. For Kerberos to work, both the client and server must have a trusted connection to the domain Key Distribution Centre (KDC). The KDC distributes the shared secret keys to allow encryption to take place. Both computers also need to be able to access Active Directory directory services and the forest root domain is the centre of Kerberos authentication referrals.

In the next part I'll move on to talking about configuring Kerberos.

Continue reading...


 

Joining FLAC files March 31st, 2009

Mike

I just bought myself a shiny new portable audio player (I was about to write MP3 player but realised I didn’t buy it to play MP3s primarily so that would have been somewhat redundant). I went for a Cowon iAudio 7 (Silver, 16GB). There were a few reasons for this:

  1. Up to 60 hours of battery life (claimed)
  2. 16GB flash memory
  3. Reasonable price (less than £120 inc. postage at time of purchase)
  4. Generally good reports of sound quality
  5. Ability to play many audio formats (particularly FLAC).

Why are those things a big deal? Well, battery life is because I see this as a very sensible alternative to buying a CD changer for my new car (probably cheaper and I can take it to my next car). Sound quality is important because anyone that knows me also knows I’m an audiophile. Finally, the killer feature is the ability to play many formats, in particular FLAC. Being an audiophile, I’m moving towards ripping CDs as FLAC instead of MP3.

However, I’d read there was one gotcha – a lack of support for gapless playback. The solution? Well, rather obviously, rip mix CDs as one file (I don’t care about skipping tracks in the car). Hang on, surely there’s a way to combine FLAC files automatically, I thought (since I’m not going to want to rip/store only one file on my HDD). The answer is the rather useful shntool. A very simple command line tool (available for Linux and Windows – I like it already :) ) that will stick together a bunch of audio files and spit out a WAV (or, with a bit of work and very simple scripting, another compressed audio file).

I’ve used it on Windows only so far and simply stuck it in a directory that I added to the PATH environment variable. I did the same for the FLAC tools. The really neat part of this is that shntool can read a list of files to stitch from a text file. So, if you rip with something like CDex and create a playlist, you can then feed shntool the playlist to stick the files in order. Brilliant! Then run the WAV through the FLAC encoder again and you have one big file. If you’re feeling adventurous, shntool supports supplying a choice of encoder and parameters to do the whole thing in one go. So far I’ve been lazy, so all I do is something like this:


shntool join -F playlist.m3u
flac -o mixname.flac -8 joined.wav

Continue reading...