During my employment at my last job as an anything and everything Technician with my good friend Mark. We ran into, as you can imagine, a lot of hard drive problems. Sometimes our last resort to get data back for a customer was to run a program called SpinRite. This worked for drives that had just enough life in them. The next problem we ran into was a lack of machines to run these drives on. A whole machine used for one drive for more than a couple hours meant we were way less productive. Our solution, run SpinRite as a virtual machine. The process for getting this going wasn't hard but we would tend to forget the steps and get angry because one thing or another wouldn't work. So I took the liberty of creating a simple little script and when it is ran as administrator it takes care of everything, even starts the virtual machine with the hard drive attached to it. As with most scripts written by someone else, I do not take responsibility for you using it blindly or improperly. With that said, I have used it on many different machines with no problems. Good luck with your hard drive woes.


  • VirtualBox
  • SpinRite

Few words on the script. Use Disk Management to get the disk number of the hard drive you would like to run SpinRite on. Make sure you set the variables (case sensitive) EXEC, DEST, and VMNAME for the correct install location of VirtualBox and where you want the raw disk to be created. VMNAME is what you have named the SpinRite virtual machine. DKPTTXT is the location you want the temprorary text file saved for DISKPART to read. Make sure to run this as administrator!

:: Created by: Josh Hostetler
:: Created on: 1/4/14
:: Name:       makeRawDisk.cmd
:: Purpose:    Auto create virtual hard disk
::               and dismount with proper attributes
::               the physical hard disk for use with
::               a SpinRite Virtual Hard Disk.
@echo off

SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%

if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)

set /p diskNum=What is the Disk number?:
set EXEC="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
set DEST="C:\Users\Joshua\Desktop\disk%diskNum%%dtStamp%.vmdk"
set VMNAME=spinrite
set COMMAKE=internalcommands createrawvmdk -filename %DEST% -rawdisk "\\.\PhysicalDrive%diskNum%"
set COMADD=storageattach %VMNAME% --storagectl "IDE" --device 0 --port 0 --type hdd --medium %DEST%
set DKPTTXT="C:\Users\Joshua\Desktop\dkpt.txt"


echo sel dis %diskNum% > %DKPTTXT%
echo offline disk >> %DKPTTXT%
echo attributes disk clear readonly >> %DKPTTXT%


call %EXEC% %COMADD%
call %EXEC% startvm %VMNAME%