forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Windows Indexing Server access using a small VDS Script....

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
Andy_Fletcher
Contributor
Contributor


Joined: 10 Jun 2003
Posts: 90
Location: Somerset, United Kingdom

PostPosted: Tue May 15, 2007 3:11 pm    Post subject: Windows Indexing Server access using a small VDS Script.... Reply with quote

Hi guys, long time no speak.

It's been a while since I tried to do any script work at home.
But I have set myself a project to try and utilise Searching content of documents on my server.
I have Index server running and want to write a little applet to search the index for files containing Words and Phrases.

Question: Has anyone out there tried to do this ? could someone give me a Non techy explanation of how to achieve this ?

Many thanks for all or any help

hope to hear soon
Andy F
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri May 18, 2007 1:47 pm    Post subject: Reply with quote

Andy,
I have been waiting to see if anyone had any ideas about how to do this before I replied but it seems that no one else knows. It is possible to communicate with the index server service but you would have to use my GadgetX.dll to do this. You would need to use the ActiveX features of my DLL to communicate with the isxxo.query object on the Index Server. Once you create that object you would set several of it's properties such as Catalog, query string, Columns you want to gather info for, and a few others. Then you would call the CreateRecordSet method on the object and walk through the record set for each record the index server returned.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri May 18, 2007 8:03 pm    Post subject: Reply with quote

Andy,
I went ahead and did you a little favor. Below is a script I wrote that will allow you to perform queries against the local Index Service.

Code:

#-----------------------------------------------------------------------------#
#                                                                             #
# Demo of how to query Windows Indexing Service with VDS and GadgetX.         #
# You must have Windows Indexing Service running for this to work.            #
#                                                                             #
# Author:  Johnny Kinsey                                                      #
#                                                                             #
# Copyright: Copyright © 2007 DragonSphere Software                           #
#                                                                             #
#-----------------------------------------------------------------------------#

Title Access Indexing Service
If @Greater(@Name(@SYSINFO(DSVER)),4)
  External GadgetX.dll,@SysInfo(DSVER)
  # GadgetX Commands
  #DEFINE COMMAND,GadgetX,DEFINE,OLE,Set
  # GadgetX Functions
  #DEFINE FUNCTION,GadgetX,OLE,Get
Else
  Warn This Example uses VDS 5 or above syntax.
  Stop
End

# The following line is required
Ole Init
# The following line is optional
# it is here for debugging your script
# Ole Exceptions,SHOW

Define Variable,Object,objIndexServerAdmin
Define Variable,Object,objCurrentCatalog
Define Variable,Object,objQueryIndexServer
Define Variable,Object,objRecordSet

# Indexing Service Administration Type Library 1.0
##################################################################
#Create the object Indexing Service Administration Object
##################################################################
Set objIndexServerAdmin,@Ole(Create,Microsoft.ISAdm,NULL)

##################################################################
# set property MachineName to local machine
# you can only set this 1 time per session.
# You must free the object and create a new object before you
# can change the Machine name
#################################################################
%%MachineName = "."
Ole Set,objIndexServerAdmin,"MachineName = ^B",%%MachineName

# Is the Indexing Service running on this machine
%A = @Ole(Call,objIndexServerAdmin,^b,"IsRunning")
If @Null(%A)
  # If the Indexing Service is not running
  Warn The Indexing Service is not running on %%MachineName@CR()Please start the service and try this program again.
  Goto Close 
  # Note you could start the service at this point if you like with the line below
  # Ole Call,objIndexServerAdmin,"Start"
End

  DIALOG CREATE,Access Indexing Service,-1,0,597,481
REM *** Modified by Dialog Designer on 5/18/2007 - 15:13 ***
  DIALOG ADD,TEXT,txt_catalogs,24,30,105,13,Index Catalogs
  DIALOG ADD,COMBO,cbo_catalogs,40,29
  DIALOG ADD,EDIT,edt_search,87,29,464,19
  DIALOG ADD,BUTTON,btn_search,84,496,64,24,Search
  DIALOG ADD,TEXT,txt_search,71,31,113,13,Enter your query below
  DIALOG ADD,TABLE,tbl_results,142,31,530,304,#[80]|Rank[80]|Title[120]|Size[80]|Modified[80]|Path[200],,COLUMNSORT
  DIALOG ADD,TEXT,txt_results,125,35,,,Results
  DIALOG ADD,TEXT,txt_sortby,23,232,,,Sort By
  DIALOG ADD,COMBO,cbo_sortby,41,230,77,21,Rank
  DIALOG ADD,TEXT,txt_orderby,24,332,,,Order By
  DIALOG ADD,COMBO,cbo_orderby,40,328,180,21,Descending
DIALOG SHOW
################################################################
# Get a list of Catalogs on the specified machine
################################################################
# Initialize the Catalog Enumerator
%A = @Ole(Call,objIndexServerAdmin,^b,"FindFirstCatalog")
If %A
  ################################################
  # Loop until we get all the configured Catalogs
  ################################################
  Repeat
    # Gets current catalog
    Set objCurrentCatalog,@Ole(Call,objIndexServerAdmin,^o,"GetCatalog")
    If @Get(objCurrentCatalog)
      # Get CatalogName and add it to our combo box
      List Add,cbo_catalogs,@Ole(Get,objCurrentCatalog,^B,"CatalogName")
    End
  Until @Null(@Ole(Call,IAdminIndexServer,^b,"FindNextCatalog"))
End

If @Get(objIndexServerAdmin)
  # We are done with the
  # Index Server Admin object
  # so free the object.
  Ole Free,Object,objIndexServerAdmin
End

List Add,cbo_sortby,Rank
List Add,cbo_sortby,Title
List Add,cbo_sortby,Size
List Add,cbo_sortby,Modified
List Add,cbo_sortby,Path

List Add,cbo_orderby,Descending
List Add,cbo_orderby,Ascending

:evloop
  Repeat
    wait event
    %E = @event()
    If %E
      GoSub %E
    End
  Until @Equal(%E,CLOSE)
Exit

:BTN_SEARCHBUTTON
  %%Catalog = @dlgtext(cbo_catalogs)
  %%QueryString = @dlgtext(edt_search)
  %%SortBy = @dlgtext(cbo_sortby)
  %%OrderBy = @dlgtext(cbo_orderby)
  If @Both(%%Catalog,%%QueryString)
    #######################################
    # Create the Index Server Query object
    #######################################
    Set objQueryIndexServer,@Ole(Create,IXSSO.Query,NULL)
    If @Get(objQueryIndexServer)
      # Set some properties just to get started
      List create,1
     
      # Set the catalog the user wants to query
      If %%MachineName
        # Check to see if this is the local machine
        If @UnEqual(%%MachineName,".")
          # If this is a remote machine
          List Add,1,Catalog=query://%%MachineName/%%Catalog
        Else
          # If this is the local machine
          List Add,1,Catalog=%%Catalog
        End
      Else
        # No machine name so this must be local
        List Add,1,Catalog=%%Catalog
      End
     
      # Allow enumeration
      List Add,1,AllowEnumeration=True
     
      # Set the sort by and order by
      If @Equal(%%OrderBy,Descending)
        %%OrderBy = d
      ElsIf @Equal(%%OrderBy,Ascending)
        %%OrderBy = a
      Else
        %%OrderBy = d
      End
      If @Equal(%%SortBy,Rank)
        %%SortBy = rank
      ElsIf @Equal(%%SortBy,Title)
        %%SortBy = doctitle
      ElsIf @Equal(%%SortBy,Size)
        %%SortBy = size
      ElsIf @Equal(%%SortBy,Modified)
        %%SortBy = write
      ElsIf @Equal(%%SortBy,Path)
        %%SortBy = path
      Else
        %%SortBy = rank
      End
      List Add,1,SortBy=%%SortBy [%%OrderBy]
     
      # Set the columns we want to display
      List Add,1,"Columns=rank, doctitle, size, write, path"
     
      # Set the users Query String
      If @Greater(@Pos(@chr(40),%%QueryString),0)
        List Add,1,Query=%%QueryString     
      Else
        List Add,1,Query=@chr(40)%%QueryString@chr(41)
      End
     
      ##################################
      # Apply all the properties above
      ##################################
      Ole SetPropertyList,objQueryIndexServer,@Text(1)
     
      ###################################################
      # Get the list of records
      ###################################################
      Set objRecordSet,@Ole(Call,objQueryIndexServer,^o,"CreateRecordset(^B)",sequential)
      If @Get(objRecordSet)
        If @Ole(Get,objRecordSet,^b,EOF)
          # If we are at the end here then no records were found
          Dialog Set,txt_results,0 results found:
          List clear,tbl_results
        Else
          List clear,tbl_results
          # If we are here then at least 1 record was found
          # Loop through the records until we get all of them in the Table
          %%TotalRecords = @Ole(Get,objRecordSet,^d,RecordCount)
          If @UnEqual(%%TotalRecords,-1)
            Dialog Set,txt_results,%%TotalRecords results found:
          End
          %%Records =
          %%cnt = 1
          While @Not(@Ole(Get,objRecordSet,^b,EOF))
            %%Rank = @Ole(Get,objRecordSet,^B,"Fields(^B)",Rank)
            %%doctitle = @Ole(Get,objRecordSet,^B,"Fields(^B)",doctitle)
            %%size = @Ole(Get,objRecordSet,^B,"Fields(^B)",size)
            %%write = @Ole(Get,objRecordSet,^D,"Fields(^B)",write)
            If %%write
              %%LastModified = @datetime(ddddd t,%%write)
            End
            %%path = @Ole(Get,objRecordSet,^B,"Fields(^B)",path)
            If %%doctitle
              %%Record = %%cnt@tab()%%Rank@tab()%%doctitle@tab()%%size@tab()%%LastModified@tab()%%path
            Else
              %%Record = %%cnt@tab()%%Rank@tab()@Name(%%path).@Ext(%%path)@tab()%%size@tab()%%LastModified@tab()%%path
            End
            If %%Records
              %%Records = %%Records@CR()%%Record
            Else
              %%Records = %%Record
            End
            %%cnt = @succ(%%cnt)
            Ole Call,objRecordSet,MoveNext
          Wend
          List Assign,tbl_results,%%Records
          If @Equal(%%TotalRecords,-1)
            Dialog Set,txt_results,%%cnt results found:
          End
        End
      Else
        # If we are at this point we didn't get a RecordSet object at all
        Dialog Set,txt_results,0 results found:
        List clear,tbl_results
      End
      # We are done with this search so clean up.
      List clear,1
      List close,1
      Ole Free,Object,objQueryIndexServer
    End
  End
Exit

:CLOSE
  # The lines below are required to be called
  # before your script exits
  If @Get(objIndexServerAdmin)
    # Free the Object variable
    Ole Free,Object,objIndexServerAdmin
  End
  # The following line is optional
  # it is here for debugging your script
  # Ole Exceptions,HIDE
  # The following line is required to be
  # the very last executed line in your script
  Ole UnInit
Exit

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri May 18, 2007 9:04 pm    Post subject: Reply with quote

Andy,
I made a small change to the code above. Now you can get fancy with your searches... Try placing this in the search edit box (@contents "Windows XP") & (@write > -1y)

Some keywords you can use in the search...

Contents
The Contents keyword defines words or phrases that you want to find in the body of the target documents.

@contents web server software
Search for documents containing the words web, server, and software

@contents “web server software”
Search for documents containing the phrase “web server software”

@contents web near software
Search for documents that have the word web near to the word software. The resulting documents are ranked by how close the words are to each other

Write
If you want to find files that have been modified since a certain time, you may use the Write keyword. The unique aspect of the Write keyword is the ability to utilize a time parameter in the search.

@write > -1n
Documents modified in the last minute

@write > -1h
Documents modified in the last hour

@write > -1d
Documents modified in the last day

@write > -1w
Documents modified in the last week

@write > -1m
Documents modified in the last month

@write > -1q
Documents modified in the last quarter

@write > -1y
Documents modified in the last year

@write 02/01/11
Documents modified since January 11, 2002


Size
The Size keyword allows you to search for documents of a particular size.

@size > 1024
Returns all documents larger than one kilobyte

@size > 1024 & < 1048576
Returns all documents larger than one kilobyte but smaller than one megabyte

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Andy_Fletcher
Contributor
Contributor


Joined: 10 Jun 2003
Posts: 90
Location: Somerset, United Kingdom

PostPosted: Thu May 24, 2007 6:08 pm    Post subject: Re: Query to Index Server... Reply with quote

Whow !!!! Shocked
First I must apologise for not having got back to you sooner I have been traveling away from home since last week and this was the first chance I had to check my personal stuff online Sad

I have to say I am totally surprised to get any help at all as I have been searching around else where and there is very little help at all.

This all looks brilliant and thanks for all your help with example script etc.

I guess I need to download your programme extention yes ?

Can you provide me with instructions etc and I'll go right ahead...

Is there a cost involved ?

Thanks for you help once again DragonSphere.
Much appreciated

Best regards
Andy F



dragonsphere wrote:
Andy,
I made a small change to the code above. Now you can get fancy with your searches... Try placing this in the search edit box (@contents "Windows XP") & (@write > -1y)

Some keywords you can use in the search...

Contents
The Contents keyword defines words or phrases that you want to find in the body of the target documents.

@contents web server software
Search for documents containing the words web, server, and software

@contents “web server software”
Search for documents containing the phrase “web server software”

@contents web near software
Search for documents that have the word web near to the word software. The resulting documents are ranked by how close the words are to each other

Write
If you want to find files that have been modified since a certain time, you may use the Write keyword. The unique aspect of the Write keyword is the ability to utilize a time parameter in the search.

@write > -1n
Documents modified in the last minute

@write > -1h
Documents modified in the last hour

@write > -1d
Documents modified in the last day

@write > -1w
Documents modified in the last week

@write > -1m
Documents modified in the last month

@write > -1q
Documents modified in the last quarter

@write > -1y
Documents modified in the last year

@write 02/01/11
Documents modified since January 11, 2002


Size
The Size keyword allows you to search for documents of a particular size.

@size > 1024
Returns all documents larger than one kilobyte

@size > 1024 & < 1048576
Returns all documents larger than one kilobyte but smaller than one megabyte
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu May 24, 2007 6:50 pm    Post subject: Reply with quote

Andy,
My DLL is listed here at VDSWorld.com or you can goto http://www.dragonsphere.net and download it there. Yes there is a cost involved. The DLL is $69 via Paypal or $79 via ShareIt. Once you register the DLL you will be given access to my Support website's. Also there is more that you can do with this demo. To me this is just the tip of the IceBurg for what is possible.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Andy_Fletcher
Contributor
Contributor


Joined: 10 Jun 2003
Posts: 90
Location: Somerset, United Kingdom

PostPosted: Mon May 28, 2007 3:21 pm    Post subject: Re: Accessing Windows Index..... Reply with quote

Many thanks, I will download and try out the demo. Much appreciated help so far amy need to come back too you with more questions.....

Regards
Andy F


dragonsphere wrote:
Andy,
My DLL is listed here at VDSWorld.com or you can goto http://www.dragonsphere.net and download it there. Yes there is a cost involved. The DLL is $69 via Paypal or $79 via ShareIt. Once you register the DLL you will be given access to my Support website's. Also there is more that you can do with this demo. To me this is just the tip of the IceBurg for what is possible.
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Jun 07, 2007 1:32 pm    Post subject: Reply with quote

Andy,
I have posted an update to the DLL please download and try out the latest build thks.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Andy_Fletcher
Contributor
Contributor


Joined: 10 Jun 2003
Posts: 90
Location: Somerset, United Kingdom

PostPosted: Sun Jun 10, 2007 4:34 pm    Post subject: Reply with quote

Hi there, many thanks for letting me know about the update dll. I will try and download and try it out during the next week or so. Been hectic at work the last 2 weeks and I am away in Brussels on an IP congress most of this week coming.

I do appreciate all your efforts and will defo be bying the dll based on my initial evaluation.

Regards
Andy F.....

dragonsphere wrote:
Andy,
I have posted an update to the DLL please download and try out the latest build thks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group