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

Wednesday 13 October 2010

Shrink of SQL log files

Microsoft SQL 2008 can sometimes be tricky to shrink the log files in a maintenance plan. This will force the shrink of the log files:

sp_MSForEachDb 'IF ''?'' NOT IN (''master'', ''tempdb'', ''tempdev'', ''model'', ''msdb'')
AND (SELECT recovery_model FROM master.sys.databases WHERE name = '
'?'') = 1
AND (SELECT is_read_only FROM master.sys.databases WHERE name = '
'?'') = 0
BEGIN
declare @LogFile nvarchar(2000)
USE [?]
SELECT @LogFile = sys.database_files.name
FROM sys.database_files
WHERE (sys.database_files.type = 1)
PRINT @LogFile
EXEC('
'ALTER DATABASE [?] SET RECOVERY SIMPLE'')
DBCC SHRINKFILE (@LogFile, 1)
EXEC('
'ALTER DATABASE [?] SET RECOVERY FULL'')
END'

Sunday 10 October 2010

GazoPa - advanced image search

In the previous post I've mentioned TinyEye, but while exploring the web I've come across GazoPa.com, an even more advanced image search engine where we can search for similar images, or even sketch a draw of what we are searching for. Very cool!