Showing posts with label WinXP. Show all posts
Showing posts with label WinXP. Show all posts

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

Tuesday, 10 August 2010

Nircmd - when you need batch stuff on remote computers

Nircmd is quite an handy utility, it saves me a lot of work when I need something changed on my site computers.
A sample that shows the flexibility of this great and freeware tool:
- Detect and repair of MS Office is not working since I had a change of the server where Microsoft Office sources where used to install Office, or I want to add a new path (the installer can work with multiple source definitions):
nircmd elevatecmd remote \\hostname_of_computer regsetval sz "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9040110900063D11C8EF10054038389C\SourceList\Net" "2" "\\new_server\O2003pro3\source"

explanation:

elevatecmd - used to ensure you run the command with administrator rights
remote - run the command remotelly on \\hostname_of_computer
regsetval - set the registry value
sz - the value type is string
"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9040110900063D11C8EF10054038389C\SourceList\Net" - key in registry

    "2" - value name in registry
    "\\new_server\O2003pro3\source" - value data in registry

    If you need to apply that same fix on multiple remote computers, you can do it like this:
    nircmd elevatecmd multiremote "c:\hostnames.txt" sz "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9040110900063D11C8EF10054038389C\SourceList\Net" "2" "\\new_server\O2003pro3\source"


    The file c:\hostnames.txt must contain host names of the computers where you want this "fix" to be installed (line by line).

    (more to come)