Thursday, 14 October 2010

Dealing with mixed architectures on Windows

I'm deploying Windows 7 while keeping Windows XP machines at the same time. We have to create some registry entries for both x86 and x64 so the way I to do it is to create a bath file that runs like this:

@echo off
If %PROCESSOR_ARCHITECTURE% == x86 (
 set arch=%windir%\system32
 GOTO X86
) ELSE (
 set arch=%windir%\syswow64
 GOTO X64
)

:X86
REM Put here your X86 stuff
GOTO Final

:X64
REM Put here your X64 stuff
GOTO Final

:Final
%arch%\REG QUERY "HKLM\SOFTWARE\software name"
IF %Errorlevel% == 1 GOTO ADDREG
Exit

:ADDREG
%arch%\REG ADD "HKLM\SOFTWARE\software name" /v "key" /t REG_SZ /d "text" /f

No comments:

Post a Comment