Thursday, November 17, 2005

Battyness today!

Again, some more .bat scripting to make my life a bit easier!
This time its SQL Enterprise Manager that is misbehaving; for whatever reason the wrong DLL's get registered and when you try to connect to any SQL database server you get and OLE 13686 error saying that you must upgrade Enterprise manager.
What you do is unregister some DLLs, copy the proper ones back in from the SQL install media and then re-register the new DLLs. IN my case the install media lives on a network drive.

@ECHO OFF
:: SQLSRVR.bat
:: Written by Daniel McLaughlin
:: http://danmacs.blogspot.com
ECHO Mounting Network Share as Local Drive
NET USE t: \\NET IP ADDRESS\share\Applications\sql2000\x86\binn /PERSISTENT:NO

CLS
ECHO *********************************WARNING*********************************
ECHO * You Should only run this if you are receiving the OLE 16386 Error *
ECHO * This assumes that you are using the default directory structure *
ECHO * i.e. .../program files/Microsoft SQL Server *
ECHO *********************************WARNING*********************************
ECHO.
ECHO.
PAUSE
ECHO.
ECHO.
ECHO *********************************INFO*********************************
ECHO You Will now unregister the DLLs invlolved with
ECHO SQL Enterprise Manager 2000
ECHO Five (5) Information boxes will appear, click OK on each
ECHO *********************************INFO*********************************
ECHO.
ECHO.
ECHO.
PAUSE

CD "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"

REGSVR32 /u dtsui.dll
REGSVR32 /u sqlns.dll
REGSVR32 /u sqldmo.dll
REGSVR32 /u sqllex.dll
REGSVR32 /u sqlmmc.dll

ECHO.
ECHO *********************************INFO*********************************
ECHO You Will now re-register the DLLs invlolved with
ECHO SQL Enterprise Manager 2000
ECHO Five (5) Information boxes will appear, click OK on each
PAUSE

ECHO STEP 1
ECHO.
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtsui.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlns.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqllex.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll"

ECHO STEP 2
ECHO.
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtsui.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlns.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqllex.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll"
CD \

ECHO STEP 3
ECHO.
XCOPY "t:\dtsui.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqlns.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqldmo.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqllex.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqlmmc.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"

cd "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
REGSVR32 dtsui.dll
REGSVR32 sqlns.dll
REGSVR32 sqldmo.dll
REGSVR32 sqllex.dll
REGSVR32 sqlmmc.dll


ECHO File Copy Successful
ECHO Thank You For Using this utility
net use t: /d
PAUSE
cd \
CLS


To use this script, CD to the directory where it lives and run it from the command line with one additional parameter, the drive that Enterprise Manager is installed on. so for example

c:\> sqlservr.bat c


No comments: