I used to write an article, “Run SPM2, SPM5, and SPM8 concurrently.” Though this is a smart way to run different version of SPM, we need to prepare scripts separately. So I came up with another script, called “SPM switcher”. This script brings up a dialog and you can select the version of SPM you want to run.
- Make a directory where you want to save scripts. (e.g. C:\Users\foo\Documents\MATLAB\)
- Add the directory to the path in Matlab. (File -> Set Path -> Add path)
- put spm_rmpath.m in SPM2 and SPM99 directory.
You find this file in SPM5 or SPM8 directory. You can just copy it from SPM5/8 to SPM2/99 directory.
- save switchspm.m in the directory you prepared.
- edit switchspm.m and change “spm_path=’C:\spm\'” according to your circumstance.
Typing switchspm in Matlab command window will bring up a dialog below and you can run different version of SPM easily.

Download switchspm.m (Right click –> Save as)
%switchspm: Run different version of SPM
%This tiny script prompts the dialog which SPM version you want to run.
%Prerequisites
%1. Each version of SPM is supporsed to be located under spm_path.
%2. Please copy spm_rmpath.m from SPM5 or later and put it into SPM99 and
% SPM2 direcotry. Otherwise, Path removal won't work correctly.
%3. Please change the SPM path according to your environment
%%%Please change the path below according to your environment%%%
spm_path='C:\spm\';
%%%
%The path for each version of SPM
spm99_path=fullfile(spm_path,'spm99');
spm2_path=fullfile(spm_path,'spm2');
spm5_path=fullfile(spm_path,'spm5');
spm8_path=fullfile(spm_path,'spm8');
spm12_path=fullfile(spm_path,'spm12');
str = ['spm99 '; 'spm2 '; 'spm5 '; 'spm8 '; 'spm12'];
spmver = listdlg('PromptString','SPM ver you want to run...',...
'SelectionMode','single',...
'ListString',str);
switch spmver
case 1, %spm99
% remove spm path
while true
try
spm_rmpath
catch break;
end;
end;
% add spm99 path
addpath(spm99_path);
% run spm99
spm;
case 2, %spm2
% remove spm path
while true
try
spm_rmpath
catch break;
end;
end;
% add spm2 path
addpath(spm2_path);
% run spm2
spm;
case 3, %spm5
% remove spm path
while true
try
spm_rmpath
catch break;
end;
end;
% add spm5 path
addpath(spm5_path);
% run spm5
spm;
case 4 %spm8
% remove spm path
while true
try
spm_rmpath;
catch break;
end;
end;
% add spm8 path
addpath(spm8_path);
% run spm8
spm;
case 5 %spm12
% remove spm path
while true
try
spm_rmpath;
catch break;
end;
end;
% add spm12 path
addpath(spm12_path);
% run spm12
spm;
end