Monday, 25 August 2008

Sysadmin: AT scheduling command

A schedule to run a batch file at 0:30 AM each day Monday to Sunday.

at 00:30 /every:M,T,W,Th,F,S,Su "e:\Constant_bak.bat"

Inside batch file, it copies a file and backs it up.

copy \\ebnews99\e$\constants.asp \\ebnews99\e$\constants_bak.asp

Sunday, 24 August 2008

Sysadmin: SORT command

Handy command line utility to sort plaintext file content and output in alphanumeric order.

The "/+1" defines at which character from the beginning of a new line should the utility start ordering from.

/t is the temporary storage location used to processed the data, useful if the data exceeds available memory

/c is the output file location

sort /+1 source.txt /t c:\temp\tempstorage.txt /o c:\temp\sorted.txt

Thursday, 21 August 2008

Sysadmin: Windows XP/2000 Command List

Here's the ultimate Windows XP/2000 command list that will make any Linux user feel at home at the command prompt. A lot of these commands are intended for administrating a network, but they are great for savvy home users as well. We even listed which OS you need for these commands.

  • at (windows XP/2000)
    Scheduling utility.

  • bootcfg (XP only) This utility allows you to set up your boot options, such as your default OS and other loading options.

  • cacls (XP, 2000, & NT4.0) Changes the ACLs (security Settings) of files and folders. Very similar to chmod in Linux.

  • comp (XP & 2000) This utility is very similar to diff in Linux. Use the /? switch to get examples of command usage.

  • contig (works with NT4.0 and newer) A great defrag utility for NTFS partitions.

  • control (XP only) - unpublished!
    Allows you to launch control panel applets from the command line.

  • control userpasswords2, for example will launch a helpful local user admin utility.
  • defrag (XP only - NT4.0 and Win2k use contig) Yes, XP comes with a command line disk defrag utility. If you are running Win2k or NT4.0 there is still hope. Contig is a free defrag program that I describe on the defrag page.

  • diskpart (XP only) Use this command to manage your disk partitions. This is the text version for the GUI Disk Manager.

  • driverquery (XP only) Produces a list of drivers, their properties, and their versions. Great for computer documentation.

  • eudcedit (XP only) -

  • unpublished!
    Private Character editor. Yes with this program built into Windows XP you can create your own font!
  • findstr
    Find String - similar to Linux's Grep.

  • fsutil (XP only) - unpublished!
    This is a utility with a lot of capability. Come back soon for great examples.

  • getmac (XP & 2000) This command gets the Media Access Control (MAC) address of your network cards.

  • gpresult (XP & 2000) This generates a summary of the user settings and computer group policy settings.

  • gpupdate (XP only) Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.

  • ipconfig (XP, 2000 & NT4.0) This handy tool displays IP settings of the current computer and much more.

  • MMC (XP, 2000 & NT4.0) - Microsoft Management Console This is the master tool for Windows, it is the main interface in which all other tools use starting primarily in Windows 2000 and newer systems.

  • more Utility used to display text output one screen at a time. Ex. more c:\windows\win.ini

  • msconfig (XP only) The ultimate tool to change the services and utilities that start when your Windows machine boots up. You can also copy the executable from XP and use it in Win2k.

  • msinfo32 (XP &smp; 2000) An awesome diagnostic tool. With it you can get a list of running processes, including the residing path of the executable (great for manually removing malware) and get detailed information about hardware and system diagnostics.

  • narrator (XP only) Turns on the system narrator (can also be found in accessibility options in control panel). Will will allow your computer to dictate text to you.

  • netsh (XP & 2000) A network configuration tool console. At the 'netsh>' prompt, use the '?' to list the available commands and type "exit" to get back to a command prompt.

  • netstat (XP) A local network port tool - try netstat -ano.

  • nslookup (all) A DNS name resolution tool.

  • openfiles (XP Only)
    Allows an administrator to display or disconnect open files in XP professional. Type "openfiles /?" for a list of possible parameters.

  • Pathping (XP & 2000) A cross between the ping and traceroute utilities. Who needs Neotrace when you can use this? Type "pathping " and watch it go.

  • recover (XP & 2000) This command can recover readable information from a damaged disk and is very easy to use.

  • reg (XP & 2000) A console registry tool, great for scripting Registry edits.

  • sc (XP & 2000) A command line utility called the Service Controller. A power tool to make service changes via a logon/logoff or startup/shutdown script.

  • schtasks (XP only) A newer version of the AT command. This allows an administrator to schedule and manage scheduled tasks on a local and remote machines.

  • secedit (XP & 2000) Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain. Example to update the machine policy: secedit /refreshpolicy machine_policy /enforce To view help on this, just type secedit. NOTE: In Windows XP SP1 and news, this command is superceded by: gpupdate /force

  • sfc (XP & 2000) The system file checker scans important system files and replaces the ones you (or your applications) hacked beyond repair with the real, official Microsoft versions.

  • shutdown (XP & 2000) With this tool, You can shut down or restart your own computer, or an administrator can shut down or restart a remote computer.

  • sigverif (XP only) Microsoft has created driver signatures. A signed driver is Microsoft tested and approved. With the sigverif tool you can have all driver files analyzed to verify that they are digitally signed. Just type 'sigverif' at the command prompt.

  • systeminfo (XP only) Basic system configuration information, such as the system type, the processor type, time zone, virtual memory settings, system uptime, and much more. This program is great for creating an inventory of computers on your network.

  • sysedit (XP/2000) System Configuration File Editor. An old tool that was very handy for the Windows 9X days. msconfig is what you want to use now.

  • tasklist (XP pro only) Tasklist is the command console equivalent to the task manager in windows. It is a must have when fighting scumware and viruses. Try the command: tasklist /svc to view the memory resources your services take up.

  • taskkill (XP only) Taskkill contains the rest of the task manager functionality. It allows you to kill those unneeded or locked up applications.

  • tree (XP & 2000) An amazing experience everyone should try! This command will provide a 'family tree' style display of the drive/folder you specify.

  • WMIC (XP & 2000) Windows Management Instrumentation Command tool. This allows you to pull an amazing amount of low-level system information from a command line scripting interface.


Of course this list in note exhaustive. We wanted to focus on tools that are particularly helpful that everyone would use. For the official list, please visit: Microsoft Windows XP Pro Command Reference

Tuesday, 19 August 2008

Sysadmin: CCMexec.exe kills my pc

Since moving to a different floor at work, my PC has been going berserk. At around 10:30AM everyday the disk would thrash and run out of control. At first I thought it was the corporate virus scanner throwing a hissy-fit but downloading filemon.exe from sysinternal shows that my pc has been overtaken by this rather annoying executable - CCMEXEC.EXE.

A quick google around later, I found out that this file is used by Microsofts SMS service. Apparently used by the SMS host to deploy software and patches to desktop pc's across the corporate network. Basically another big brother tool from M$.

Killing this executable cured my PC from its spastic habits but I'll need to investigate more as to why it only runs on my PC and only at 10:30AM each day!! It is basically sucking the life force out of my HD causing it to wear and will probably make it sucidal in the end.

Thursday, 7 August 2008

TSQL: CASE statements example

select top 500 
a.SarID, 
a.Createdate as CreatedDate, 
a.ApprovedDate, 
a.CompletedDate,
CASE a.status 
WHEN 'C' THEN 'COMPLETED'
WHEN 'R' THEN 'REJECTED'
WHEN 'A' THEN 'APPROVED'
WHEN 'L' THEN 'LODGED'
WHEN 'X' THEN 'X'
WHEN 'P' THEN 'P'
ELSE 'Unknown'
END as RequestStatus, 
(select fname + ' ' + sname from intranetwarehouse..staffdetails where id = a.personid) as LodgeFor, 
a.createdby as LodgeByUsername,
a.approvedby as ApprovedByUsername,
(select fname + ' ' + sname from intranetwarehouse..staffdetails where id = a.approverid) as ApproverName,
e.name as SystemName,
CASE e.status 
WHEN 'I' THEN 'Inactive'
WHEN 'A' THEN 'Active'
ELSE 'Unknown'
END as isSystemActive,
d.name as ApplicationName,
CASE d.status 
WHEN 'I' THEN 'Inactive'
WHEN 'A' THEN 'Active'
ELSE 'Unknown'
END as isApplicationActive,
c.name as OptionName,
CASE c.status 
WHEN 'I' THEN 'Inactive'
WHEN 'A' THEN 'Active'
ELSE 'Unknown'
END as isOptionActive,
CASE b.status 
WHEN 'P' THEN 'PENDING'
WHEN 'A' THEN 'APPROVED'
WHEN 'R' THEN 'REJECTED'
WHEN 'L' THEN 'LODGED'
ELSE 'Unknown'
END as OptionApprovalStatus,
a.Comment
from ittservice..sar as a, ittservice..optionaccessrequests as b, ittservice..options as c, ittservice..applications as d, ittservice..systems as e
where a.sarid = b.sarid
and b.optionid = c.optionid
and c.applicationid = d.applicationid
and d.systemid = e.systemid
and year(a.createdate) = '2008'
order by a.sarid

Tuesday, 8 July 2008

Javascript: Maximize and Minimize

<SCRIPT LANGUAGE="JavaScript">

function Minimize()
{
window.innerWidth = 100;
window.innerHeight = 100;
window.screenX = screen.width;
window.screenY = screen.height;
alwaysLowered = true;
}

function Maximize()
{
window.innerWidth = screen.width;
window.innerHeight = screen.height;
window.screenX = 0;
window.screenY = 0;
alwaysLowered = false;
}
</SCRIPT>

<A HREF="javascript:onClick=Minimize()">Minimize</A>
<A HREF="javascript:onClick=Maximize()">Maximize</A> 

<html>
<head>
<title>Maximize Your Potential</title>
<script>
function maximize() {
  window.moveTo(0, 0);
  window.resizeTo(screen.width, screen.height);
}
maximize();
</script>
</head>
<body>
<h1 align="center">Maximize Your Potential</h1>
This page is self-maximizing.
</body>
</html>

function openWindowMax(location) {
sizeX = screen.width
sizeY = screen.height-50
var posx = (screen.availWidth-sizeX)/2;
var posy = (screen.availHeight-sizeY)/2;
var windowString = 'toolbar=no,location=no,menubar=no,status=no,resizable=no,directories=no,scrollbars=yes,copyhistory=no,width='+sizeX+',height='+sizeY+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
newWindow = window.open(location, "", windowString);
newWindow.moveTo(0,0);
}

Thursday, 26 June 2008

IIS : SMTP Email howto use telnet to test

>>telnet fic 26

220 FIC Microsoft ESMT
830 ready at Fri, 2 Dec 2005 09:24:56 +0000 mail Service, Version: 6.0.3790.1

>>HELO me.localdomain

250 FIC Hello [1.1.1.1]

>>mail FROM: example@example2.com

250 2.1.0 example@example2.com....Sender OK

>>RCPT TO: example2@example2.com

250 2.1.5 example2@example2.com

>>DATA

354 Start mail input; end with .

>>Just a test
>>.
>>

250 2.6.0 Queued mail f
or delivery

>>quit

221 2.0.0 FIC Service closing transmission channel

Monday, 23 June 2008

Javascript: Validate file extension when uploading files

/*check file extension*/
function CheckFileExtension(obj){
val=obj.value.substring(obj.value.length-4,obj.value.length);
  if (val!='.jpg'&&val!='.gif'&&val!='.bmp'&&val!='.png'&&val!='.jpeg'&&val!='.JPG'&&val!='.GIF'&&val!='.BMP'&&val!='.PNG'&&val!='.JPEG'){
   return false;
  }
}

Tuesday, 17 June 2008

ASP: URLDecode

' -----------------------------------------
' URL decode to retrieve the original value

Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If

' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")

' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")

If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
Next
End If

URLDecode = sOutput
End Function

Indexing Service: Setting up indexing service

Stolen from http://www.cscoding.com/article/4/4017.html

Introduction




A lot of web sites provide search capabilities, where you can simple type
several words, press "Search" button, and you'll receive a list of pages which
contains these words. It's simple. But how can you implement these features in
your own web application? Yes, you have to use indexing service which will index
your files or web pages. After that you can use full text search
features.



There are a lot of solutions which allow you to provide this functionality in
your application. One of them is Microsoft Indexing Service. It's part of
Windows 2000 and later Windows versions. So, if you provide only Windows
solutions (ASP.NET web application, Windows Forms application, etc.) you have to
see this Microsoft's product.



On of the biggest goal of Indexing Service that it's totally free. You can
use it without any restriction or additional licenses. I think that this is so
big goal, because other indexing products cost a lot of money. If you develop
small or middle project you don't want to pay thousands dollars for full text
search tool.



If you will choose Indexing Service you should remember that it can index
only file system. For example, you can't use it for indexing files which stored
in your database. This is a big minus of Microsoft Indexing Service, but I
believe that you will solve this limitation.



In this manual I'll try to describe you how to install, configure and use
Microsoft Indexing Service. We'll develop simple application which will allow
you to use full text search features for web pages which located on your local
file system.




Installation and configuration Microsoft Indexing Service




If you are using Windows XP or later Windows version, you'll use Microsoft
Indexing Service 3.0. And if you're still using Windows 2000, you'll use
Microsoft Indexing Service 2.0. This service is installed to your machine by
default. But you could disable its installation, when you installed operating
system. You have to check that Indexing Service is installed on your machine. To
do this you go to "Add or Remove Programs" in your Control Panel. Choose
"Add/Remove Windows Components" there. You have to check that "Indexing Service"
is installed. If it isn't installed, install it, please.



Microsoft Indexing Service Installation



Now Microsoft Indexing Service has been installed, and you can configure it.
Please, open "Computer Management" configuration tool. Choose "Services and
Applications", "Indexing Service". In this entry you can manage your Microsoft
Indexing Service.



First of all you should create new catalog in Indexing Service for folder
which will contain indexes. Open context menu for "Indexing Service" and choose
"Catalog" in "New" submenu. You type "Name", choose "Location" and press
"OK".



New Catalog Creation



After that you have to add folders which will be indexed. For this choose
"Directories" entry, open its context menu and choose "Directory" in "New"
submenu. Choose folder with your documents in opened dialog box and press "OK"
button to include selected directory to the index. If you decide to exclude
folder from existing index, please choose "No" for "Include in Index?" parameter
in this dialog window. This parameter is "Yes" by default.



New Directory Creation



If your Indexing Service is started it will index new catalog. Otherwise you
should start Indexing Service and it will index catalog automatically. You can
create or recreate index folder manually. To do this you should open context
menu for specified folder in existing catalog and choose "Rescan (Full)" or
"Rescan (Incremental)" in "All Tasks" submenu. Of course, your Microsoft
Indexing Service has to be started at this time.



If you choose "Indexing Service" entry in your "Computer Management" you will
see state of the Indexing Service. Sometimes this information can help you if
you have big storage and can't find file there.



There is another important setting of Indexing Service – "Indexing Service
Usage". This setting allow you say Indexing Service how often it should update
indexes. For example, if you application use only static storage service have to
update index not so often as if you use dynamic data storage and your data is
updated very often. To configure this parameter you should open context menu for
"Indexing Service" entry and choose "Tune Performance" in "All Tasks"
submenu.



Indexing Service Usage Configuration



Now you can check index. To do this please choose "Query the Catalog" in your
catalog. You'll see form which allows you search something in your index. First
of all you can test simple full text search. Enter something in query field and
press "Search" button. After that you will see files which contain entered
words. Of course, you can execute more difficult queries using this tool. Choose
"Advanced query" if you want execute some queries. After that you can use
Microsoft Indexing Service queries to take some needed information. This query
language is the same language as SQL, but it contains some syntax
extensions.




Query Microsoft Indexing Service




You can use SQL to query Microsoft Indexing service. But there are several
extensions for Indexing Service's SQL dialect which you have to know.



The most useful command, when you use Microsoft Indexing Service, is SELECT
command. It's clear, because you shouldn't add, delete or update information in
your indexes. You only select query Indexing Service to retrieve some
information about indexed files.Let's see example query:


SELECT Path FROM SCOPE() WHERE FREETEXT(Contents, 'Hello World')<br /></pre><br />
<p>This query returns you all paths to files which contain "Hello World" text.
And it can help me describe you Microsoft Indexing Service's SQL
extensions.</p><br />
<p>First of all let's speak about <em>FROM</em> expression. In this example we
query all data which index contain. <em>SCOPE()</em> function allows you tell
Indexing Service which data you decide to examine. By default, if you don't use
any parameters, it examines all data in your index. This function can optimize
your queries, because it can limit indexes for search. For example, you can use
<em>SCOPE ('"/books"') </em>. At this time you will query only "/books" folder,
not all folders in your index. Query execution speed will be more that if you
would use simple <em>SCOPE()</em> function. For more search limitation you can
use special traversal types. For example, <em>SCOPE ('DEEP TRAVERSAL OF
"/books"') </em>. If you use this expression, Indexing Service will search in
"/books" directory and in all directories beneath them. If you use <em>SHALLOW
TRAVERSAL</em> Microsoft Indexing service will examine only "/books" directory.
For example, <em>SCOPE('SHALLOW TRAVERSAL OF "/books"') </em>.</p><br />
<p><em>WHERE</em> expression is the same as in SQL standard, but there are few
extensions for it too. There are Comparison Predicates. You can see they in this
table:</p><br />
<table border="1" cellspacing="0" width="60%"><br />
<tbody>
<tr style="background-color: silver;"><br />
<td>Operator</td><br />
<td>Symbol</td><br />
<td>Example</td><br /></tr><br />
<tr><br />
<td>Equals</td><br />
<td>=</td><br />
<td><em>WHERE DocAuthor = 'John Doe'</em></td><br /></tr><br />
<tr><br />
<td>Not equals</td><br />
<td>!= or <></td><br />
<td><em>WHERE DocTitle != 'Finance'</em></td><br /></tr><br />
<tr><br />
<td>Less than</td><br />
<td><</td><br />
<td><em>WHERE WordCount < 1000</em></td><br /></tr><br />
<tr><br />
<td>Greater than</td><br />
<td>></td><br />
<td><em>WHERE WordCount > 500</em></td><br /></tr><br />
<tr><br />
<td>Less than or equal to</td><br />
<td><=</td><br />
<td><em>WHERE WordCount <= 500</em></td><br /></tr><br />
<tr><br />
<td>Greater than or equal to</td><br />
<td>>=</td><br />
<td><em>WHERE WordCount >= 500</em></td><br /></tr><br /></tbody></table><br />
<p>You also can use Boolean operators which are evaluated using following
rules:</p><br />
<ul><br /><li><em>NOT</em> is evaluated before <em>AND</em>. <em>NOT</em> can only occur
after <em>AND</em> (as in <em>AND NOT</em>; the combination <em>OR NOT</em> is
not allowed). <br />
</li><li><em>AND</em> is evaluated before <em>OR</em>. <br />
</li><li><em>AND</em> expressions are associative and can be applied in any order.
For example, <em>A AND B AND C</em>, is the same as <em>(A AND B) AND C</em>,
which is the same as <em>A AND (B AND C) </em>. <br />
</li><li><em>OR</em> expressions are associative and can be applied in any order.
<br /></li></ul><br />
<p>There is LIKE predicate too. But there are several predicates which extend
SQL language:</p><br />
<ul><br /><li><em>ARRAY</em>. This predicate performs comparisons of two arrays using
logical operators. For example, <em>... WHERE username = SOME ARRAY ['Admin' ,
'root'] </em>. This example returns you files which contain username parameter
and this parameter is 'Admin' or 'root'. <br />
</li><li><em>CONTAINS</em>. This predicate using for full text search. For example,
<em>…WHERE CONTAINS(country,'"USA" OR "Russia"') </em>. This example return
files, which contains country property and this property is "USA" or "Russia".
<br />
</li><li><em>FREETEXT</em>. This predicate allows you find words and phrases in
indexed files. It's better to use it if you need find anything in the content of
your files. For example, <em>…WHERE CONTAINS(Contents,'Hello World !!!') </em>.
<br />
</li><li><em>MATHCES</em>. Predicate performs queries using regular-expression
pattern. It's more powerful than <em>LIKE</em> predicate. For example, <em>…
WHERE MATCHES (Contents, '|(USA|)|{1|}' ) </em>. This example matches any string
in which exactly one instance of the pattern "BUSA" occur. <br /></li></ul><br />
<p>For additional information you have to see <a href="http://msdn2.microsoft.com/en-us/library/aa163263.aspx">Indexing Service
Articles on MSDN web site</a>.</p><br />
<p>Now you know how to prepare queries to Microsoft Indexing Service, but you
still need take list of properties, which can be used in your queries. There are
a lot of default properties for each index, which you can find in following
table.</p><br />
<table border="1" cellspacing="0" width="60%"><br />
<tbody>
<tr style="background-color: silver;"><br />
<td>Friendly Name</td><br />
<td>Datatype</td><br />
<td>Property</td><br /></tr><br />
<tr><br />
<td>A_HRef</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML HREF. This property name was created for Microsoft® Site Server
and corresponds with the Indexing Service property name HtmlHRef. Can be queried
but not retrieved.</td><br /></tr><br />
<tr><br />
<td>Access</td><br />
<td>VT_FILETIME</td><br />
<td>Last time file was accessed.</td><br /></tr><br />
<tr><br />
<td>All</td><br />
<td>(not applicable)</td><br />
<td>Searches every property for a string. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>AllocSize</td><br />
<td>DBTYPE_I8</td><br />
<td>Size of disk allocation for file.</td><br /></tr><br />
<tr><br />
<td>Attrib</td><br />
<td>DBTYPE_UI4</td><br />
<td>File attributes. Documented in Win32 SDK.</td><br /></tr><br />
<tr><br />
<td>ClassId</td><br />
<td>DBTYPE_GUID</td><br />
<td>Class ID of object, for example, WordPerfect, Word, and so
on.</td><br /></tr><br />
<tr><br />
<td>Characterization</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Characterization, or abstract, of document. Computed by Indexing
Service.</td><br /></tr><br />
<tr><br />
<td>Contents</td><br />
<td>(not applicable)</td><br />
<td>Main contents of file. Can be queried but not retrieved.</td><br /></tr><br />
<tr><br />
<td>Create</td><br />
<td>VT_FILETIME</td><br />
<td>Time file was created.</td><br /></tr><br />
<tr><br />
<td>Directory</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Physical path to the file, not including the file name.</td><br /></tr><br />
<tr><br />
<td>DocAppName</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Name of application that created the file.</td><br /></tr><br />
<tr><br />
<td>DocAuthor</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Author of document.</td><br /></tr><br />
<tr><br />
<td>DocByteCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of bytes in a document.</td><br /></tr><br />
<tr><br />
<td>DocCategory</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Type of document such as a memo, schedule, or whitepaper.</td><br /></tr><br />
<tr><br />
<td>DocCharCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of characters in document.</td><br /></tr><br />
<tr><br />
<td>DocComments</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Comments about document.</td><br /></tr><br />
<tr><br />
<td>DocCompany</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Name of the company for which the document was written.</td><br /></tr><br />
<tr><br />
<td>DocCreatedTm</td><br />
<td>VT_FILETIME</td><br />
<td>Time document was created.</td><br /></tr><br />
<tr><br />
<td>DocEditTime</td><br />
<td>VT_FILETIME</td><br />
<td>Total time spent editing document.</td><br /></tr><br />
<tr><br />
<td>DocHiddenCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of hidden slides in a Microsoft® PowerPoint
document.</td><br /></tr><br />
<tr><br />
<td>DocKeywords</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Document keywords.</td><br /></tr><br />
<tr><br />
<td>DocLastAuthor</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Most recent user who edited document.</td><br /></tr><br />
<tr><br />
<td>DocLastPrinted</td><br />
<td>VT_FILETIME</td><br />
<td>Time document was last printed.</td><br /></tr><br />
<tr><br />
<td>DocLastSavedTm</td><br />
<td>VT_FILETIME</td><br />
<td>Time document was last saved.</td><br /></tr><br />
<tr><br />
<td>DocLineCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of lines contained in a document.</td><br /></tr><br />
<tr><br />
<td>DocManager</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Name of the manager of the document's author.</td><br /></tr><br />
<tr><br />
<td>DocNoteCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of pages with notes in a PowerPoint document.</td><br /></tr><br />
<tr><br />
<td>DocPageCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of pages in document.</td><br /></tr><br />
<tr><br />
<td>DocParaCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of paragraphs in a document.</td><br /></tr><br />
<tr><br />
<td>DocPartTitles</td><br />
<td>DBTYPE_STR | DBTYPE_VECTOR</td><br />
<td>Names of document parts. For example, in Excel part titles are the names of
spread sheets, in PowerPoint slide titles, and in Word for Windows the names of
the documents in the master document.</td><br /></tr><br />
<tr><br />
<td>DocPresentationTarget</td><br />
<td>DBTYPE_STR | DBTYPE_BYREF</td><br />
<td>Target format (35mm, printer, video, and so on) for a presentation in
PowerPoint.</td><br /></tr><br />
<tr><br />
<td>DocRevNumber</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Current version number of document.</td><br /></tr><br />
<tr><br />
<td>DocSlideCount</td><br />
<td>DBTYPE_14</td><br />
<td>Number of slides in a PowerPoint document.</td><br /></tr><br />
<tr><br />
<td>DocSubject</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Subject of document.</td><br /></tr><br />
<tr><br />
<td>DocTemplate</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Name of template for document.</td><br /></tr><br />
<tr><br />
<td>DocTitle</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Title of document.</td><br /></tr><br />
<tr><br />
<td>DocWordCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of words in document.</td><br /></tr><br />
<tr><br />
<td>FileIndex</td><br />
<td>DBTYPE_I8</td><br />
<td>Unique ID of file.</td><br /></tr><br />
<tr><br />
<td>FileName</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Name of file.</td><br /></tr><br />
<tr><br />
<td>HitCount</td><br />
<td>DBTYPE_I4</td><br />
<td>Number of hits (words matching query) in file.</td><br /></tr><br />
<tr><br />
<td>HtmlHRef</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML HREF. Can be queried but not retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading1</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H1. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading2</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H2. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading3</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H3. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading4</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H4. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading5</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H5. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>HtmlHeading6</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Text of HTML document in style H6. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>Img_Alt</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Alternate text for <IMG> tags. Can be queried but not
retrieved.</td><br /></tr><br />
<tr><br />
<td>Path</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Full physical path to file, including file name.</td><br /></tr><br />
<tr><br />
<td>Rank</td><br />
<td>DBTYPE_I4</td><br />
<td>Rank of row. Ranges from 0 to 1000. Larger numbers indicate better
matches.</td><br /></tr><br />
<tr><br />
<td>RankVector</td><br />
<td>DBTYPE_I4 | DBTYPE_VECTOR</td><br />
<td>Ranks of individual components of a vector query.</td><br /></tr><br />
<tr><br />
<td>ShortFileName</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Short (8.3) file name.</td><br /></tr><br />
<tr><br />
<td>Size</td><br />
<td>DBTYPE_I8</td><br />
<td>Size of file, in bytes.</td><br /></tr><br />
<tr><br />
<td>USN</td><br />
<td>DBTYPE_I8</td><br />
<td>Update Sequence Number. NTFS drives only.</td><br /></tr><br />
<tr><br />
<td>VPath</td><br />
<td>DBTYPE_WSTR | DBTYPE_BYREF</td><br />
<td>Full virtual path to file, including file name. If more than one possible
path, then the best match for the specific query is chosen.</td><br /></tr><br />
<tr><br />
<td>WorkId</td><br />
<td>DBTYPE_I4</td><br />
<td>Internal ID for file. Used within Indexing Service.</td><br /></tr><br />
<tr><br />
<td>Write</td><br />
<td>VT_FILETIME</td><br />
<td>Last time file was written.</td><br /></tr><br /></tbody></table><br />
<p>As you can see, there are a lot indexed properties for each file, but
sometime you want to extend this list.</p><br /><br />
<h2>How to add new properties for indexed file</h2><br /><br />
<p>First of all I have to say, that this feature works only for web pages,
because it is base on HTML <em><meta></em> tag.</p><br />
<p>Now you have several indexed web pages and you want to add several special
properties for them. For example, you will add "country" and "city" properties.
First of all you should add <em><meta></em> tags to all files which will
contain these new properties:</p><br /><pre lang="html"><meta name="country" content="Russia" /><br /><br /><meta name="city" content="Moscow" /><br /><br /></pre><br />
<p>After these changes you have to restart Indexing Service. Now you can open
entry "Properties" and see that right now Microsoft Indexing Service knows about
your special parameters for files. But still you can't use these new parameters
in queries.</p><br />
<p>Select "Properties" node of your catalog and choose property, which you added
to the files using <em><meta></em> tag. Double click on this property.
Switch on "Cached" checkbox and choose data type for new property in opened
dialog box.</p><br />
<p><img alt="Microsoft Indexing Service Installation" src="http://file.cscoding.com/file/8%5C4017%5CMicrosoft_Indexing_Service_HOW_TO5.jpg" /></p><br />
<p>After that you should create Column Definition File which contains
information about your new added parameters. File could have ".idq" extension,
but this isn't important. Column Definition File uses following format:</p><br /><pre>[Names]<br />Propertyname( Data type ) = GUID [<span class="cpp-string">"Name"</span> | Property ID] <br /></pre><br />
<p>Data type parameter is optional. If you don't define it, Microsoft Indexing
Service will take data type from parameters definition for your catalog.</p><br />
<p>For my example it contains this:</p><br /><pre>[Names]<br />country = d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1 <span class="cpp-string">"country"</span><br />city = d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1 <span class="cpp-string">"city"</span><br /></pre><br />
<p>All these data you can take from dialog box for properties
configuration.</p><br />
<p>After Columns Definition File is created, information about this file has to
be added to Indexing Service registry settings. Add String entry named
<em>"DefaultColumnFile" </em>to the registry key
<em>"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ContentIndexCommon"</em>.
<em>"DefaultColumnFile" </em>should contain full path to your Columns Definition
File.</p><br />
<p>Restart Microsoft Indexing Service. After that run full rescan of your
indexed folder. Now you are able to use these new parameters in your
queries.</p><br /><br />
<h2>Using Microsoft Indexing Service in .NET applications</h2><br /><br />
<p>Microsoft Indexing Service exposes itself to the developer as OLE DB
provider. Its name is MSIDXS. You can use ADO.NET for query you Indexing
Service. To do this you have to create new System.Data.OleDb.OleDbConnection
object using this sample connection string:</p><br /><pre>Provider= <span class="cpp-string">"MSIDXS"</span>;Data Source=<span class="cpp-string">"Documents"</span><br /></pre><br />
<p>In Data Source parameter you should use name of your catalog in indexing
Service.</p><br />
<p>Let's create sample code which will query Indexing Service for few words in
files' contents. <br />In this sample there is queryString variable. It is an
instance of SearchParameters structure. This structure contains information
about Data Source and Query string. Here is the definition of this
structure:</p><br /><pre lang="cs">struct SearchParameters<br />{<br /> private string storage;<br /><br /> public string Storage<br /> {<br /> get { return storage; }<br /> set { storage = value; }<br /> }<br /><br /> private string query;<br /><br /> public string Query<br /> {<br /> get { return query; }<br /> set { query = value; }<br /> }<br />}<br /></pre><br />
<p>First of all you create new OleDbConnection object:</p><br /><pre lang="cs">string connectionString = string.Format(<span class="cpp-string">"Provider= \"</span>MSIDXS\<span class="cpp-string">";Data Source=\"</span>{0}\<span class="cpp-string">";"</span>, queryString.Storage);<br />OleDbConnection connection = new OleDbConnection(connectionString);<br /></pre><br />
<p>After that you create new OleDbCommand which associated with this
connection:</p><br /><pre lang="cs">string query = string.Format(@<span class="cpp-string">"SELECT Path FROM scope() WHERE FREETEXT(Contents, '{0}')"</span>, queryString.Query);<br />OleDbCommand command = new OleDbCommand(query, connection); <br /></pre><br />
<p>Note that MSIDXS provider doesn't support commands with parameters. This is
bad. I hope that Microsoft will fix this issue in next version of Microsoft
Indexing Service.</p><br />
<p>Now you are able to execute this command and retrieve list of files which
contain selected text:</p><br /><pre lang="cs">connection.Open();<br /><br />ArrayList result = new ArrayList();<br /><br />OleDbDataReader reader = command.ExecuteReader();<br />while (reader.Read())<br />{<br /> result.Add(reader.GetString(0));<br />}<br /><br />connection.Close();<br />


In this code checking returned value to NULL is not necessary, because
Indexing Service always returns path to found file.




Summary




Microsoft Indexing Service is totally free and powerful product which
included to Windows 2000 or later Windows versions. But it's simple very much.
You can easy create indexes. You can also query these indexes using OLE DB data
provider. If you are working with Microsoft .NET it will easy very much. In this
article I tried to describe you how to install, configure and query. I also
recommend you see my example, which I attached to this manual. This example will
show you how to use full text search features. I hope that this article will
help you to start using Indexing Service.