home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 April / PCpro_2007_04.ISO / files / dsl / NVinst.exe / Scripts / Searcher / Auto_Re_Search.nvs next >
Encoding:
Text File  |  2007-02-10  |  3.1 KB  |  83 lines

  1. Program Auto_Re_Search;
  2. {
  3. AutoReSearch v1.0
  4. This script automatically starts search process only for not searched hosts every
  5. specified time period specified count times after every search that was started
  6. not by AutoReSearch itself
  7. }
  8.  
  9. const REMAINS_RE_SEARCH_PERIOD = 5;//In minutes, interval between starting of
  10.                                     //re-searching on still not searched hosts
  11.  
  12. const REMAINS_RE_SEARCH_COUNT  = 5;//How many times start new re-searching on not searched
  13.                                    //hosts after one external global search finished
  14.                                    //If -1 then not limited
  15.  
  16.                                    //Be carefull with this settings to exclude
  17.                                    //starting of re-search process on time
  18.                                    //when global search should be started
  19.                                    //If re-search is active then global earch
  20.                                    //will not be started automatically
  21.  
  22.  
  23. var DisabledHostTable,MyDisabledHostTable,SearchedHostTable:TStringList;
  24.     i,v,v1,v2,MyStartCounter:integer;
  25.     StartedByMe,AutoImportAll,AutoImportOnline:boolean;
  26. Begin
  27.  
  28. DisabledHostTable:=TStringList.Create;DisabledHostTable.CaseSensitive:=false;
  29. MyDisabledHostTable:=TStringList.Create;MyDisabledHostTable.CaseSensitive:=false;
  30. SearchedHostTable:=TStringList.Create;SearchedHostTable.CaseSensitive:=false;
  31. StartedByMe:=false;
  32. if REMAINS_RE_SEARCH_COUNT>0 then MyStartCounter:=REMAINS_RE_SEARCH_COUNT
  33.                              else MyStartCounter:=0;
  34. SetTimer(REMAINS_RE_SEARCH_PERIOD*60000);
  35.  
  36. repeat
  37.  v:=WaitEvent(v1,v2);
  38.  if v=8 then
  39.   begin
  40.   if (not StartedByMe) and ((NVSearcher.GetStatus and 1)=0)
  41.   and ((REMAINS_RE_SEARCH_COUNT<0) or (MyStartCounter<REMAINS_RE_SEARCH_COUNT))then
  42.    begin
  43.    AutoImportAll:=NVSearcher.HostTable_AutoImportAll;
  44.    AutoImportOnline:=NVSearcher.HostTable_AutoImportOnline;
  45.    NVSearcher.HostTable_EnumSearchedHosts(SearchedHostTable);
  46.    if MyStartCounter=0 then
  47.     begin
  48.     NVSearcher.HostTable_EnumDisabledHosts(DisabledHostTable);
  49.     MyDisabledHostTable.Assign(DisabledHostTable);
  50.     end;
  51.  
  52.  
  53.    if SearchedHostTable.Count<>0 then
  54.    for i:=0 to SearchedHostTable.Count-1 do
  55.    if MyDisabledHostTable.IndexOf(SearchedHostTable.Strings[i])=-1 then
  56.    MyDisabledHostTable.Add(SearchedHostTable.Strings[i]);
  57.  
  58.    NVSearcher.HostTable_AutoImportAll:=false;
  59.    NVSearcher.HostTable_AutoImportOnline:=false;
  60.    NVSearcher.HostTable_SetDisabledHosts(MyDisabledHostTable);
  61.    MyStartCounter:=MyStartCounter+1;
  62.    StartedByMe:=true;
  63.  
  64.    NVSearcher.Start;
  65.    end;
  66.   end else if (v=NMNP_ALERT) and (v1=NVALERT_NETSEARCHER) and (v2<=0) then
  67.   begin
  68.   if StartedByMe then
  69.    begin
  70.    NVSearcher.HostTable_AutoImportAll:=AutoImportAll;
  71.    NVSearcher.HostTable_AutoImportOnline:=AutoImportOnline;
  72.    NVSearcher.HostTable_SetDisabledHosts(DisabledHostTable);
  73.    StartedByMe:=false;
  74.    end else MyStartCounter:=0;
  75.   end;
  76.  until v=0;
  77.  
  78. SetTimer(0);
  79. DisabledHostTable.Free;
  80. MyDisabledHostTable.Free;
  81. SearchedHostTable.Free;
  82. End.
  83.