gVim unattended install

I like Vim, and had need to deploy it unattended as part of our standard builds at work. Unfortunately the official installers appear to not support unattended installation natively so I ended up using the unofficial “Cream” distribution (there is a version which is just pure Vim, which I used).

Installing is easy, simply run the exe with the command line switch /S, e.g.:

gvim-7-3-98.exe /S

This works, but apparently fails to enable the right-click menu function. This is just a simple registry tweak however:

REG ADD HKEY_CLASSES_ROOT\*\shell\vim /ve /f /d "Edit with &Vim"
IF /i "%Processor_Architecture%"=="x86" REG ADD HKEY_CLASSES_ROOT\*\shell\vim\command /ve /f /d "\"C:\\Program Files\\Vim\\vim73\\gvim.exe\" \"%%1\""
IF /i "%Processor_Architecture%"=="AMD64" REG ADD HKEY_CLASSES_ROOT\*\shell\vim\command /ve /f /d "\"C:\\Program Files (x86)\\Vim\\vim73\\gvim.exe\" \"%%1\""

Finally the first time you run gVim it’ll ask you about its registered types library. You can silently do this in the background by running:

IF /i "%Processor_Architecture%"=="x86" "C:\Program Files\Vim\vim73\gvim.exe" -silent -register
IF /i "%Processor_Architecture%"=="AMD64" "C:\Program Files (x86)\Vim\vim73\gvim.exe" -silent -register

These snippets are taken from the batch file that I run to perform the unattended install, the architecture-detection is needed since Windows x64 mangles the Program Files path for WoW64 applications…