Apr 30 2008

SQL Search is Slow on the First Search

This is an Old one but some people I find still get stuck scratching their head, including me.

If you are using full Text indexing for your web based searches, you most likely don’t have Internet access on your SQL server, and this is the root cause of the search performing very slowly on the first attempt of the search, as SQL is trying to establish a connection for ‘Signature verification’

You can turn this feature off:

run

sp_fulltext_service ‘verify_signature’, 0;
GO

 

for more info go to

http://support.microsoft.com/kb/915850


Apr 28 2008

Windows Server 2003 – IIS6 Randomly Crashing

If you are finding that at random times, whether it would be daily, weekly or even monthly, that your IIS servers just stop serving pages for no apparent reason, You can do anything and everything else but yet IIS just doesn’t work, and even an ‘IISReset’ wont rectify the problem, and it seems that the only way that you can recover the IIS process to start back up again it to reboot the system.

If this sounds like your problem STOP looking you have found the answer.

But to ensure this is your problem go to the task manager and view the Non-paged kernel mode memory usage this generally will increase until the memory is exhausted.

It is related to the a memory leak which occurs in the system non-paged memory pool.

However it seems as though this leak is exposed more so when Trend’s Officescan is installed. Microsoft have released a KB on this

http://support.microsoft.com/KB/923125/EN-US

Trend also have noted this and also have fix for the problem

http://esupport.trendmicro.com/support/viewxml.do?ContentID=EN-1035794

Now you may not have Trend installed and you are still having this issue, so the point of this blog post is to simply point out that if this is happening on various servers, sit down and nut out what is the common link between all servers, have a look at all KB’s on all your vendors…. Search and you will find!


Apr 24 2008

Automate – Rename file with yesterdays Date Stamp and FTP

Today I was asked if we could automate something where a file would be FTP’d to the clients FTP server.

My answer was sure that’s as easy as pie. Then the finer details came to light.

Problem

So the the details are:

the file changes every day and must have a filename followed by the date stamp at the end of the file name.

For example: file_24042008.txt

that’s easy enough to do, But then I was told that it needed to use the following days date stamp not the current day.

Now it just became a little bit harder

Solution

Being that I am dumping the file to the clients FTP, this makes it a little easier or give me a little bit more control, As the output of the file will just be: file.txt  with that then I can script a rename of that file to: file_24042008.txt

So everyday the file.txt would be dumped in a specific directory and then renamed to the file_yesterdays date here.txt 

here is the code that was used for that part

(code was taken and modified from a user on Experts Exchange, thanks for that if your reading)

 

@echo off

set yyyy=

set $tok=1-3
for /f “tokens=1 delims=.:/-, “ %%u in (‘date /t’) do set $d1=%%u
if “%$d1:~0,1%” GTR “9″ set $tok=2-4
for /f “tokens=%$tok% delims=.:/-, “ %%u in (‘date /t’) do (
for /f “skip=1 tokens=2-4 delims=/-,().” %%x in (‘echo.^|date’) do (
    set %%x=%%u
    set %%y=%%v
    set %%z=%%w
    set $d1=
    set $tok=))

if “%yyyy%”==“” set yyyy=%yy%
if /I %yyyy% LSS 100 set /A yyyy=2000 + 1%yyyy% – 100

set CurDate=%mm%/%dd%/%yyyy%

REM Substract your days here
set /A dd=1%dd% – 100 – 1
set /A mm=1%mm% – 100

:CHKDAY

if /I %dd% GTR 0 goto DONE

set /A mm=%mm% – 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yyyy=%yyyy% – 1

:ADJUSTDAY

if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yyyy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yyyy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yyyy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY
:D ONE

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

rename “C:\Users\bradm\Desktop\ideas.txt” “ideas_%dd%-%mm%-%yyyy%.txt”

This script allows the change of the file name, with this all you have to change is:
rename "C:\Users\bradm\Desktop\ideas.txt" "ideas_%dd%-%mm%-%yyyy%.txt" 

The Next Part (FTP script)

Ok here we need to create some thing that dumps this to the FTP, again we are scripting this.

typically with in command line FTP you cant pass a variable, so we have to do all of that before we get to the FTP

So being that we are using a different script (there is no reason why you just cant do this on one script, I am just breaking it down) we then use the same as above but with a few additions

set yyyy=

set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
if "%$d1:~0,1%" GTR "9" set $tok=2-4
for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
 for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
    set %%x=%%u
    set %%y=%%v
    set %%z=%%w
    set $d1=
    set $tok=))

if "%yyyy%"=="" set yyyy=%yy%
if /I %yyyy% LSS 100 set /A yyyy=2000 + 1%yyyy% - 100

set CurDate=%mm%/%dd%/%yyyy%

REM Substract your days here
set /A dd=1%dd% - 100 - 1
set /A mm=1%mm% - 100

:CHKDAY

if /I %dd% GTR 0 goto DONE

set /A mm=%mm% - 1

if /I %mm% GTR 0 goto ADJUSTDAY

set /A mm=12
set /A yyyy=%yyyy% - 1

:ADJUSTDAY

if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
REM ** Month 12 falls through

:SET31

set /A dd=31 + %dd%

goto CHKDAY

:SET30

set /A dd=30 + %dd%

goto CHKDAY

:LEAPCHK

set /A tt=%yyyy% %% 4

if not %tt%==0 goto SET28

set /A tt=%yyyy% %% 100

if not %tt%==0 goto SET29

set /A tt=%yyyy% %% 400

if %tt%==0 goto SET29

:SET28

set /A dd=28 + %dd%

goto CHKDAY

:SET29

set /A dd=29 + %dd%

goto CHKDAY
 :D ONE

if /I %mm% LSS 10 set mm=0%mm%
if /I %dd% LSS 10 set dd=0%dd%

echo YourFTPUserHere>ftp.txt
echo yourFTPpasswordHere>>ftp.txt
echo cd C:\Users\bradm\Desktop\>>ftp.txt
echo put file_%dd%-%mm%-%yyyy%.txt>>ftp.txt
echo bye>>ftp.txt
ftp -i -s:.\ftp.txt ftp.youraddress.com.au

As you can see its using the same code above,  toward the end we are simple creating the FTP.txt that will be used to upload the file.  All you need to do is change the user, pass path and file.

If you are using these as 2 separate scripts make sure you enter a ‘call’ statement to your FTP script.


Apr 21 2008

SQL 2008 – Change ‘Edit Top 200 Rows"

Well this is a great idea from Microsoft, but what if you want them all, or you want more then 200 rows like me, I am greedy, I like everything….

Any ways I was prepared to hack the registry for this one, but it seems you don’t have to, and its in very simple to do and find… But I have one of my dev’s point it out to me as I seemed to have been blind to this, even though I was looking for it for hours, and even went into the options console…

Lesson 1 learnt, late nights and SQL don’t mix.

Lesson 2  Change the Top 200 rows

go to

Tools

Options

SQL Server Object Explorer, Expand this tree

Choose ‘Commands’

And there you go change it to your desired amount, 0 = everything!

image

Cheers


Apr 20 2008

Vista Admin Pack AD Not opening – FIXED

When I first installed the Admin pack for vista, it worked perfectly, I was able to connected to every thing with out any issues, however I did notice within in the AD MMC  the icons were not quite right, some were missing and things just were very hard to determine what was a group and what was a user, you really had to pay attention to the objects.

Or if you don’t even get that far, as there have been reports that some people are unable to connect to AD, or other MMC consoles after the installation.
The connection some how gets lost and you are unable to again connect to a MMC console.

Anyway’s there is a very easy fix.

Install the Admin pack, then run the below script.

(this is simply registering the necessary DLL’s.

@echo off

REM RegisterAdminPak.cmd
REM (c) 2006 Microsoft Corporation.  All rights reserved.

set filelist=adprop.dll azroles.dll azroleui.dll ccfg95.dll
set filelist=%filelist% certadm.dll certmmc.dll certpdef.dll certtmpl.dll
set filelist=%filelist% certxds.dll cladmwiz.dll clcfgsrv.dll clnetrex.dll
set filelist=%filelist% cluadmex.dll cluadmmc.dll cmproxy.dll cmroute.dll
set filelist=%filelist% cmutoa.dll cnet16.dll debugex.dll dfscore.dll
set filelist=%filelist% dfsgui.dll dhcpsnap.dll dnsmgr.dll domadmin.dll
set filelist=%filelist% dsadmin.dll dsuiwiz.dll imadmui.dll lrwizdll.dll
set filelist=%filelist% mprsnap.dll msclus.dll mstsmhst.dll mstsmmc.dll
set filelist=%filelist% nntpadm.dll nntpapi.dll nntpsnap.dll ntdsbsrv.dll
set filelist=%filelist% ntfrsapi.dll rasuser.dll rigpsnap.dll rsadmin.dll
set filelist=%filelist% rscommon.dll rsconn.dll rsengps.dll rsjob.dll
set filelist=%filelist% rsservps.dll rsshell.dll rssubps.dll rtrfiltr.dll
set filelist=%filelist% schmmgmt.dll tapisnap.dll tsuserex.dll vsstskex.dll
set filelist=%filelist% w95inf16.dll w95inf32.dll winsevnt.dll winsmon.dll
set filelist=%filelist% winsrpc.dll winssnap.dll ws03res.dll

for %%i in (%filelist%) do (
    echo Registering %%i ...
    regsvr32 /s %%i
)

echo.
Echo Command Completed

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }


Apr 2 2008

Cant connect to default shares within Vista

Even though by default the system drive is shared by default Vista has implemented security so that you can not connect to the administrative share ‘\\servername\c$’ If you are anything like me you live and breath using these admin shares all the time.

So it seems the only way to actually get this working is a registry entry.

***Before you perform any registry changes ensure you have a backup of it****

So here are the steps

  • Start –> Run
  • Type: ‘regedit’
  • Press enter
  • browse to the following folder: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system\
  • Right-click a blank area in the right pane
  • Click New
  • Click DWORD (32 bit) Value
  • Type: LocalAccountTokenFilterPolicy
  • Double-click the item you just created
  • Type 1 into the box
  • Click OK
  • Restart your computer
  • Now you have Administrative shares again.