home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 May / comcd0502.iso / top100com / putzi4win / setup.exe / #setuppath# / bestimme_dateityp.VBS < prev    next >
Encoding:
Text File  |  2001-09-30  |  30.5 KB  |  586 lines

  1. ' ########################################################################
  2. '
  3. '        --==** bestimme_dateityp.vbs - Version 1.1 **==--
  4. '
  5. '                ein ADD-ON zum Programm PUTZI 4 WIN
  6. '
  7. ' ------------------------------------------------------------------------
  8. '        Autor:
  9. '        ~~~~~~
  10. '        Axel Hahn * support@putzi4win.de.de
  11. '        http://www.putzi4win.de
  12. ' ------------------------------------------------------------------------
  13. '        Zweck:
  14. '        ~~~~~~
  15. '        Datei-Erweiterungen in der TYPES.DAT suchen ...
  16. '        Nach Eingabe eines Datei-Filters (auch mit Platzhalter)
  17. '        wird die Datei TYPES.DAT, die im Programm Putzi 4 Win als
  18. '        "Datenbank" von Dateitypen dient, durchsucht.
  19. '        Die Ausgabe erfolgt als Tabelle im Explorer-Fenster.
  20. ' ------------------------------------------------------------------------
  21. '        Installation:
  22. '        ~~~~~~~~~~~~~
  23. '        kopieren Sie diese Datei in den Ordner des Programmes
  24. '        Putzi4Win und starten Sie es aus diesem Ordner.
  25. ' ------------------------------------------------------------------------
  26. '        History:
  27. '        ~~~~~~~~
  28. '        2000-10-29  V1.0  erste Version von Axel Hahn
  29. '        2001-06-16  V1.1  Informationenen im Ausgabefenster erweitert:
  30. '                                * Rubriken der Dateitypen
  31. '                                * Zus.fassung der Stati aller Dateitypen
  32. '                          dieses VBScript geh÷rt nun zum Programmumfang
  33. ' ########################################################################
  34.  
  35.         Option explicit
  36.  
  37.         ' =========================================================
  38.         ' CONFIG
  39.         ' =========================================================
  40.  
  41.         ' --- Variablen ---
  42.         Dim REGINFOS, ALLINFOS, dummy, Html_Inithead, Html_HLP_Eingabe, Html_HLP_Ausgabe
  43.  
  44.         ' --- Objekte ---
  45.         Dim fso, regEx, ie4, WSHShell
  46.  
  47.         ' --- Konstanten ---
  48.         const ForReading = 1
  49.         const infofile= "TYPES.DAT"
  50.         const default_ext = "*.TMP"
  51.         const regfile = "HKCR_export.reg"
  52.         const regtmpfile = "HKCR_export.tmp"
  53.         const str_about = "bestimme_dateityp.vbs V1.1<BR>© 2000-2001 Axel Hahn"
  54.  
  55.         ' =========================================================
  56.         ' MAIN
  57.         ' =========================================================
  58.         call Init_Objects()
  59.  
  60.         ' to do:
  61.         ' call exportFromRegistry()
  62.         
  63.         call ask_user()
  64.         dummy=quit_now(0,"")
  65.  
  66.  
  67. ' ########################################################################
  68. '
  69. '       SUBS
  70. '
  71. ' ########################################################################
  72.  
  73.  
  74.         ' =========================================================
  75.         ' create all objects required in this script - then the
  76.         ' script terminates in the first function call, if someone
  77.         ' has an older version of WSH or VBScript
  78.         ' =========================================================
  79.         sub Init_Objects()
  80.  
  81.                 Dim err_oldversion, all_errors
  82.  
  83.                 err_oldversion= _
  84.                         "Anmerkung:" _
  85.                         & vbcrlf & "Evtl. liegt dies auch daran, dass Sie eine Σltere Version" _
  86.                         & vbcrlf & "des Windows Scripting Host (WSH) oder der VBScript-Engine" _
  87.                         & vbcrlf & "verwenden." _
  88.                         & vbcrlf & vbcrlf & "Ihre Engine:" _
  89.                         & vbcrlf & "Name: " & Wscript.Name & " (Version " & Wscript.Version & ")"_
  90.                         & vbcrlf & "Script-Engine: " & CStr(ScriptEngine()) _
  91.                         & " (Version " & CStr(ScriptEngineMajorVersion()) _
  92.                         & "." & CStr(ScriptEngineMinorVersion()) _
  93.                         & "; Built " & CStr(ScriptEngineBuildVersion()) & ")"
  94.  
  95.                 all_errors=""
  96.  
  97.                 On Error Resume Next
  98.  
  99.                 ' -------------------------------------------------------
  100.                 ' object: FileSystemObject
  101.                 ' -------------------------------------------------------
  102.                 Set fso = CreateObject("Scripting.FileSystemObject")
  103.                 if Err.Number>0 then
  104.                         all_errors=all_errors & _
  105.                                 "* Objekt kann nicht erstellt werden: Scripting.FileSystemObject" & _
  106.                                 vbcrlf & _
  107.                                 "   Fehlercode # " & CStr(Err.Number) & ": " & Err.Description & _
  108.                                 vbcrlf & vbcrlf
  109.                         Err.Clear
  110.                 end if
  111.  
  112.                 ' -------------------------------------------------------
  113.                 ' object: regular expressions
  114.                 ' -------------------------------------------------------
  115.                 Set regEx = New RegExp
  116.                 if Err.Number>0 then
  117.                         all_errors=all_errors & _
  118.                                 "* Objekt kann nicht erstellt werden: RegExp" & _
  119.                                 vbcrlf & _
  120.                                 "   Fehlercode # " & CStr(Err.Number) & ": " & Err.Description & _
  121.                                 vbcrlf & vbcrlf
  122.                         Err.Clear
  123.                 end if
  124.  
  125.                 ' -------------------------------------------------------
  126.                 ' object: Internet Explorer
  127.                 ' -------------------------------------------------------
  128.                 set ie4 = WScript.CreateObject("InternetExplorer.Application", "event_")
  129.                 if (err.number > 0) then
  130.                         all_errors=all_errors & _
  131.                                 "* Objekt kann nicht erstellt werden: InternetExplorer.Application" & _
  132.                                 vbcrlf & _
  133.                                 "   Fehlercode # " & CStr(Err.Number) & ": " & Err.Description & _
  134.                                 vbcrlf & vbcrlf
  135.                         Err.Clear
  136.                 else
  137.                         ie4.width = 600
  138.                         ie4.height = 400
  139.                         ie4.top = 5
  140.                         ie4.left = 5
  141.                         ie4.Toolbar = false
  142.                         ie4.Statusbar = false
  143.                         ie4.navigate _
  144.                         ("JavaScript:'<title>PUTZI 4 WIN - Ausgabe</title><body " _
  145.                                 & "scroll=yes></body>'")
  146.                         do
  147.                         loop while ie4.ReadyState<>4
  148.                 end if
  149.  
  150.  
  151.                 ' -------------------------------------------------------
  152.                 ' object: WScript Shell
  153.                 ' -------------------------------------------------------
  154.                 set WSHShell=WScript.CreateObject("WScript.Shell")
  155.                 if (err.number > 0) then
  156.                         all_errors=all_errors & _
  157.                                 "* Objekt kann nicht erstellt werden: WScript.Shell" & _
  158.                                 vbcrlf & _
  159.                                 "   Fehlercode # " & CStr(Err.Number) & ": " & Err.Description & _
  160.                                 vbcrlf & vbcrlf
  161.                         Err.Clear
  162.                 end if
  163.  
  164.                 ' -------------------------------------------------------
  165.                 ' check errors
  166.                 ' -------------------------------------------------------
  167.                 if all_errors>"" then
  168.  
  169.                         dummy=quit_now(1,all_errors & err_oldversion)
  170.  
  171.                 end if
  172.  
  173.                 ' -------------------------------------------------------
  174.                 ' eigentlich Konstanten: Hilfe-Strings
  175.                 ' -------------------------------------------------------
  176.                 Html_Inithead= "<TABLE WIDTH=100% bgcolor=#D0C0FF><TR><TD>" & _
  177.                         "<H2>Initialisierung</H2></TD>" & _
  178.                         "</TD><TD ALIGN=RIGHT VALIGN=TOP>" & str_about & "</TD></TR></TABLE><BR>" & _
  179.                         "<B>Status:</B><BR>"
  180.  
  181.                 Html_HLP_Eingabe= "<TABLE WIDTH=100% bgcolor=#D0C0FF><TR><TD>" & _
  182.                         "<H2>Hilfe zur Eingabe</H2></TD>" & _
  183.                         "</TD><TD ALIGN=RIGHT VALIGN=TOP>" & str_about & "</TD></TR></TABLE><BR>" & _
  184.                         "<B>Was ist das eigentlich hier?</B><BR>" & _
  185.                         "Geben Sie einen beliebigen Dateifilter ein - es listet Ihnen daraufhin die passenden Dateitypen auf. Die zurⁿckgelieferten Informationen stammen aus der ASCII-Datei TYPES.DAT im Programmordner des Programmes PUTZI 4 WIN.<BR><BR>" & _
  186.                         "<B>Syntax fⁿr Dateifilter</B><BR>" & _
  187.                         "GrundsΣtzlich k÷nnen beliebige Dateifilter nach der Syntax <BR>" & _
  188.                         "<B>[Dateiname].[Dateierweiterung]</B><BR> eingegeben werden. Auf Gross- " & _
  189.                         "und Kleinschreibung braucht (wie unter DOS und Windows ⁿblich) nicht " & _
  190.                         "geachtet zu werden. Auch die Verwendung von Platzhaltern ist " & _
  191.                         "m÷glich:" & _
  192.                         "<BLOCKQUOTE>" & _
  193.                         "<B>*</B> steht fⁿr mehrere beliebige oder kein Zeichen<BR>" & _
  194.                         "<B>?</B> steht fⁿr genau 1 Zeichen (*.B?K passt z.B. auf *.BAK, *.BNK, ...)" & _
  195.                         "</BLOCKQUOTE>" & _
  196.                         "Da in der Datei TYPES.DAT vorwiegend die verschiedensten" & _
  197.                         "Dateierweiterungen enthalten sind, ist die Verwendung des" & _
  198.                         "Platzhalters * als Dateiname am sinnvollsten." & _
  199.                         "" & _
  200.                         ""
  201.                 Html_HLP_Ausgabe= "<TABLE WIDTH=100% bgcolor=#D0C0FF><TR><TD>" & _
  202.                         "<H2>Hilfe zum Ausgabefenster</H2></TD>" & _
  203.                         "</TD><TD ALIGN=RIGHT VALIGN=TOP>" & str_about & "</TD></TR></TABLE><BR>" & _
  204.                         "<B>Was ist das eigentlich hier?</B><BR>" & _
  205.                         ""
  206.                 ' -------------------------------------------------------
  207.                 ' get fileinfos of TYPES.DAT
  208.                 ' -------------------------------------------------------
  209.                 ie4.visible = true
  210.                 ie4.document.body.innerHTML = Html_Inithead & "Lese " & infofile
  211.  
  212.                 ALLINFOS=readCompleteFile(infofile)
  213.  
  214.                 ' MsgBox(ALLINFOS)
  215.                 if Len(ALLINFOS)=0 then
  216.  
  217.                         dummy=quit_now(2,"Die Konfig-Datei <" & infofile & "> ist leer (???).")
  218.  
  219.                 end if
  220.  
  221.         end sub
  222.  
  223.  
  224.         ' =========================================================
  225.         ' export
  226.         ' =========================================================
  227.         sub exportFromRegistry()
  228.                 Dim cmd
  229.  
  230.                 ie4.document.body.innerHTML = Html_Inithead & "Exportiere HKEY_CLASSES_ROOT aus der Registry..."
  231.  
  232.                 ' step 1: export registry Key HKEY_CLASSES_ROOT
  233.                 RUN("regedit /E " & regfile & " HKEY_CLASSES_ROOT")
  234.  
  235.                 ' step 2: grep lines with fileextensions from output of step 1
  236.                 cmd = "%COMSPEC% /c find ""HKEY_CLASSES_ROOT\."" " & regfile & " | sort > " & regtmpfile
  237.  
  238.                 ie4.document.body.innerHTML = Html_Inithead & "ermittle registrierte Dateitypen..."
  239.  
  240.                 ' MsgBox cmd
  241.                 RUN(cmd)
  242.  
  243.                 ie4.document.body.innerHTML = Html_Inithead & "lese Textfile " & regtmpfile & "..."
  244.                 REGINFOS = readCompleteFile(regtmpfile)
  245.                 ' MsgBox(REGINFOS)
  246.  
  247.         end sub
  248.  
  249.         ' =========================================================
  250.         ' main function: ask user and create result-list
  251.         ' =========================================================
  252.         sub ask_user()
  253.  
  254.                 Dim userinput, i, count, char, char1, regpattern, result, LINE, ext, del, info
  255.                 Dim HtmlHead, HtmlOut, found_dot, tcolor, del_OK, del_warn, del_neutral
  256.                 Dim regtype, regcmd, regmime, count_reg
  257.  
  258.                 ie4.document.body.innerHTML = Html_HLP_Eingabe
  259.  
  260.                 userinput=default_ext
  261.                 do
  262.                         userinput=UCase(InputBox( _
  263.                                 "Platzhalter sind m÷glich:" & vbcrlf & _
  264.                                 "? = 1 Zeichen; * = beliebig viele Zeichen" & vbcrlf & _
  265.                                 "Beispiel: " & vbcrlf &_
  266.                                 "*.B?K passt auf *.BAK, *.BNK, ..." & vbcrlf & vbcrlf &_
  267.                                 ":h oder :? zeigen eine Hilfe." & vbcrlf, _
  268.                                 "Putzi 4 Win - Dateifilter eingeben" , _
  269.                                 userinput _
  270.                                         ))
  271.  
  272.                         select case userinput
  273.                         case "" ' do noting
  274.                         case ":H", ":?"
  275.                                 ie4.visible = true
  276.                                 ie4.document.body.innerHTML = Html_HLP_Eingabe
  277.                                 userinput=default_ext
  278.                         case else
  279.  
  280.                                 if (Mid(userinput,1,1)=".") then
  281.                                         userinput="*" &userinput
  282.                                 end if
  283.  
  284.                                 ' -----------------------------------------------------
  285.                                 ' built pattern for regexp object
  286.                                 ' -----------------------------------------------------
  287.                                 regpattern=""
  288.                                 i=0
  289.                                 found_dot=false
  290.                                 Do
  291.                                         i=i+1
  292.                                         char=Mid(userinput,i,1)
  293.                                         select case char
  294.                                                 case "." found_dot=true
  295.                                                          char1="\."
  296.                                                 case "?" char1="."
  297.                                                 case "*" char1=".*"
  298.                                                 case "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z" char1=char
  299.                                                 case "0","1","2","3","4","5","6","7","8","9" char1=char
  300.                                                 case else char1="\" & char
  301.                                                 ' case else char1=char
  302.                                         end select
  303.                                               regpattern = regpattern + char1
  304.                                 Loop While i < Len(userinput)
  305.  
  306.                                 ' regpattern2
  307.                                 ' MsgBox(regpattern2)
  308.  
  309.                                 ' \n fuer Zeilenumbruch
  310.                                 regpattern= "\n" & regpattern & "\ .*"
  311.  
  312.                                 ' -----------------------------------------------------
  313.                                 ' search for fileinfos
  314.                                 ' -----------------------------------------------------
  315.  
  316.                                 HtmlHead= "<TABLE WIDTH=100% bgcolor=#D0C0FF><TR><TD>"
  317.                                 HtmlHead= HtmlHead & "<H2>Ausgabe zu Dateifilter <" & userinput & "></H2></TD>"
  318.                                 HtmlHead= HtmlHead & "</TD><TD ALIGN=RIGHT VALIGN=TOP>" & str_about & "</TD></TR></TABLE><BR>"
  319.                                 if (found_dot=false) then
  320.                                         HtmlHead= HtmlHead & "HINWEIS:<BR>Im angegebenen Dateifilter ist kein Punkt enthalten. Es können dadurch falsche Ergebnisse zurückgeliefert werden.<BR><BR>"
  321.                                 end if
  322.  
  323.                                 ie4.visible = true
  324.                                 ie4.document.body.innerHTML = HtmlHead & "STATUS:<BR><B>* Suche läuft...</B><BR>* Stelle Ergebnisse zusammmen..."
  325.                                 result=""
  326.  
  327.                                 ' MsgBox("regpattern=" & regpattern & vbcrlf & "Ergebnis:" & RegExpTest(regpattern, ALLINFOS))
  328.                                 result=RegExpTest(regpattern, ALLINFOS)
  329.                                 ie4.document.body.innerHTML = HtmlHead & "STATUS:<BR>* Suche läuft...<BR><B>* Stelle Ergebnisse zusammmen...</B>"
  330.  
  331.                                 count=0
  332.                                 del_OK=0
  333.                                 del_warn=0
  334.                                 del_neutral=0
  335.                                 count_reg=0
  336.  
  337.                                 ' MsgBox(result)
  338.                                 if (result="") then
  339.                                         HtmlOut= "<H2>kein Treffer :-(</H2>"
  340.                                 else
  341.                                         HtmlOut="<TABLE WIDTH=100% CELLSPACING=0>" & _
  342.                                         "<TR><TD bgcolor=#D0C0FF><B>Dateityp</B></TD><TD bgcolor=#D0C0FF ALIGN=CENTER><B>temp?</B></TD><TD bgcolor=#D0C0FF><B>Beschreibung</B></TD></TR>"
  343.  
  344.                                         For Each LINE In Split(result, vbcrlf)
  345.                                                 if (LINE>"") then
  346.                                                         ext=RTrim(Mid(LINE,1,16))
  347.                                                         if (InStr(ext, ".")=0) then
  348.                                                                 ext = ext & "*.*"
  349.                                                         end if
  350.                                                         del=Mid(LINE,17,1)
  351.                                                         info=Mid(LINE,18)
  352.  
  353.                                                         ' MsgBox("ext = " & ext & " | del = " & del)
  354.                                                         if (RegExpTest(regpattern, ext & " ")>"") then
  355.                                                                 count=count+1
  356.                                                                 if ((count/2) = (count\2)) then
  357.                                                                         tcolor="#E0E0E0"
  358.                                                                 else
  359.                                                                         tcolor="#F0F0F0"
  360.                                                                 end if
  361.                                                                 HtmlOut= HtmlOut & "<TR><TD VALIGN=TOP bgcolor=" & tcolor & "><B>"  & ext & "</B></TD>"
  362.                                                                 if (del="+") then
  363.                                                                         HtmlOut= HtmlOut & "<TD bgcolor=90E090 align=center VALIGN=TOP>ja</TD>"
  364.                                                                         del_OK=del_OK + 1
  365.                                                                 elseif (del="-") then
  366.                                                                         HtmlOut= HtmlOut & "<TD bgcolor=F0c0c0 align=center VALIGN=TOP>!!!</TD>"
  367.                                                                         del_warn=del_warn + 1
  368.                                                                 else
  369.                                                                         HtmlOut = HtmlOut & "<TD align=center VALIGN=TOP bgcolor=" & tcolor & ">?</TD>"
  370.                                                                         del_neutral=del_neutral + 1
  371.                                                                 end if
  372.                                                                 HtmlOut= HtmlOut & "<TD bgcolor=" & tcolor & ">" & info & "<BR>"
  373.  
  374.                                                                 ext=Mid(ext,2,16)
  375.                                                                 regtype=RegKey_value("HKEY_CLASSES_ROOT\" & ext & "\")
  376.                                                                 if NOT(regtype=false) then
  377.                                                                         count_reg = count_reg + 1
  378.                                                                         regmime=RegKey_value("HKEY_CLASSES_ROOT\" & ext & "\Content Type")
  379.                                                                         regcmd=RegKey_value("HKEY_CLASSES_ROOT\" & ext & "\shell\open\command\")
  380.                                                                         if (regcmd=false) then regcmd=RegKey_value("HKEY_CLASSES_ROOT\" & regtype & "\shell\open\command\")
  381.  
  382.                                                                         if (regtype=false) then regmime="- kein Eintrag -"
  383.                                                                         if (regmime=false) then regmime="- kein Eintrag -"
  384.                                                                         if (regcmd=false) then regcmd="- kein Eintrag -"
  385.  
  386.                                                                         HtmlOut= HtmlOut & "<FONT COLOR=#A04040>" & _
  387.                                                                                 "<B>!!! registrierter Dateityp !!!</B><BR>" & _
  388.                                                                                 "Typ: " & regtype & "<BR>" & _
  389.                                                                                 "MIME: " & regmime & "<BR>" & _
  390.                                                                                 "╓ffnen: " & regcmd & "<BR>" & _
  391.                                                                                 "</FONT>"
  392.                                                                 end if
  393.                                                                 HtmlOut= HtmlOut & "</TD></TR>"
  394.  
  395.                                                         end if
  396.                                                 end if
  397.                                         Next
  398.  
  399.                                         HtmlHead = HtmlHead & "<TABLE BORDER=0 BGCOLOR=#D0C0FF WIDTH=10%><TR><TD><B>Zusammenfassung:</B></TD></TR></TABLE>" & _
  400.                                                 "<TABLE WIDTH=100% BORDER=0 BGCOLOR=#F0F0F0><TR><TD VALIGN=TOP ALIGN=RIGHT WIDTH=10%><B>" & infofile & ":</B></TD>" & _
  401.                                                 "<TD ALIGN=RIGHT WIDTH=30%>Treffer in dieser Datei:</TD><TD><B>" & count & "</B></TD></TR>" & _
  402.                                                 "<TR><TD></TD><TD VALIGN=TOP ALIGN=RIGHT>gefundene Stati:</TD><TD>"
  403.                                         if (del_OK>0)      then HtmlHead=HtmlHead & "<FONT color=#207020>" & del_OK & " x bedenkenlos l÷schbar</FONT><BR>"
  404.                                         if (del_neutral>0) then HtmlHead=HtmlHead & "<FONT color=#A0A020>" & del_neutral & " x neutral</FONT><BR>"
  405.                                         if (del_warn>0)    then HtmlHead=HtmlHead & "<FONT color=#A02020>" & del_warn & " x !!! Warnungen !!!</FONT><BR>"
  406.                                         if (count_reg>0)   then HtmlHead=HtmlHead & "</TR><TR><TD ALIGN=RIGHT><BR><B>Registry:</B></TD><TD COLSPAN=2><FONT color=#A02020><BR>" & count_reg & " x registrierte Dateitypen gefunden !!!</FONT><BR>"
  407.  
  408.                                         HtmlHead = HtmlHead & "</TD></TR></TABLE><BR>"
  409.                                         HtmlOut  = HtmlOut & "</TABLE>"
  410.                                 end if
  411.  
  412.                                 ' -----------------------------------------------------
  413.                                 ' search in registry (not supported yet)
  414.                                 ' -----------------------------------------------------
  415.                                 ' For Each LINE In Split(REGINFOS, vbcrlf)
  416.                                 '    if (LINE>"") then
  417.                                        ' MsgBox LINE
  418.                                        ' result=RegExpTest("\.bat", LINE)
  419.                                        ' if (result>"") then
  420.                                        '   MsgBox result
  421.                                        ' end if
  422.                                 '    end if
  423.                                 ' next
  424.  
  425.                                 ' -----------------------------------------------------
  426.                                 ' show results
  427.                                 ' -----------------------------------------------------
  428.                                 ie4.document.body.innerHTML = HtmlHead & HtmlOut
  429.                         end select
  430.  
  431.                 loop until (userinput="")
  432.  
  433.         end sub
  434.  
  435.  
  436.         ' =========================================================
  437.         ' free all objects and quit
  438.         ' =========================================================
  439.         function quit_now(RetCode, strmessage)
  440.  
  441.                 On Error Resume Next
  442.  
  443.                 REGINFOS = ""
  444.                 ALLINFOS = ""
  445.  
  446.                 WScript.Disconnect fso
  447.                 set fso=nothing
  448.  
  449.                 WScript.Disconnect regEx
  450.                 set regEx=nothing
  451.  
  452.                 ie4.Quit
  453.                 WScript.Disconnect ie4
  454.                 set ie4=nothing
  455.  
  456.                 WScript.Disconnect WSHShell
  457.                 set WSHShell=nothing
  458.  
  459.                 if Len(strmessage)>0 then
  460.                         MsgBox strmessage
  461.                 end if
  462.  
  463.                 ' dummy=MsgBox(RetCode,strmessage)
  464.                 WScript.Quit RetCode
  465.  
  466.         end function
  467.  
  468.  
  469. ' ########################################################################
  470.  
  471.  
  472.         ' =========================================================
  473.         ' read complete file
  474.         '       IN: filename of configfile
  475.         '       OUT: string with text of configfile
  476.         ' =========================================================
  477.         function readCompleteFile(filename)
  478.                 dim result, Line, filehandle, section
  479.  
  480.                 On Error Resume next
  481.  
  482.                 section=""
  483.                 if fso.FileExists(filename) then
  484.                         Set filehandle = fso.OpenTextFile(filename, ForReading, False)
  485.                         if fso.GetFile(filename).size>0 then
  486.  
  487.                                 Do
  488.                                         Line=filehandle.ReadLine
  489.                                         if InStr(1, Line, ">>> ") then
  490.                                                 section="<B>" & Mid(Line,5,1000) & "</B><BR>"
  491.                                         end if
  492.  
  493.                                         ' MsgBox(filename & " | Zeile = " & Line)
  494.  
  495.                                         if (NOT(Mid(Line,1,1)="|") _
  496.                                         and NOT(Mid(Line,1,3)=">>>")) then
  497.                                                 result=result & Mid(Line,1,17) & section & Mid(Line,18,1000) & vbCrLF
  498.                                                 ' result=result & Line
  499.                                         end if
  500.  
  501.                                 Loop until (filehandle.AtEndOfStream)
  502.                         else
  503.                                 Msgbox_result=MsgBox("Dateigroesse von <" & filename & "> ist " &fso.GetFile(filename).size& " Bytes!!!")
  504.                         end if
  505.                         filehandle.Close
  506.                 else
  507.                         dummy=quit_now(3, "Die Datei <" & filename &  "> wurde nicht gefunden!" & vbcrlf & vbcrlf & _
  508.                                         "Bitte kopieren Sie das Skript <" & wscript.scriptname & "> in den" & vbcrlf & _
  509.                                         "Ordner des Programmes PUTZI 4 WIN und starten Sie es dort erneut." )
  510.                 end if
  511.  
  512.                 ' MsgBox(result)
  513.                 readCompleteFile=result
  514.         end function
  515.  
  516.         ' =========================================================
  517.         ' test regexp
  518.         ' =========================================================
  519.         Function RegExpTest(patrn, strng)
  520.                 Dim Match, Matches, RetStr
  521.  
  522.                 ' MsgBox("regexp-Aufruf:" & patrn & " | " &  strng)
  523.  
  524.                 regEx.Pattern = patrn   ' Set pattern.
  525.                 regEx.IgnoreCase = True   ' Set case insensitivity.
  526.                 regEx.Global = True   ' Set global applicability.
  527.                 Set Matches = regEx.Execute(strng)   ' Execute search.
  528.                 For Each Match in Matches   ' Iterate Matches collection.
  529.                         RetStr = RetStr & Match.Value & vbcrlf
  530.                         ' RetStr = RetStr & "Match found at position "
  531.                         ' RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
  532.                         ' RetStr = RetStr & Match.Value & "'." & vbCRLF
  533.                 Next
  534.  
  535.                 ' MsgBox("RetStr = " & RetStr)
  536.  
  537.                 RegExpTest = RetStr
  538.         End Function
  539.  
  540.  
  541.         ' =========================================================
  542.         ' capture close event of MSIE window
  543.         ' =========================================================
  544.         sub event_onQuit
  545.                 dummy=quit_now(8,"Sie haben das Fenster des MS Internet Explorer" & vbcrlf & _
  546.                         "geschlossen. Das VBSkript wird daher ebenfalls beendet.")
  547.         end sub
  548.  
  549.  
  550.         ' =========================================================
  551.         ' read value of registry key
  552.         ' =========================================================
  553.         function RegKey_value(regkey)
  554.                 dim wert
  555.                 On Error Resume Next
  556.                 wert=WSHShell.RegRead(regkey)
  557.                 if (Err.Number>0) or (wert=vbempty) then
  558.                         wert=false
  559.                 end if
  560.                 RegKey_value=wert
  561.         end function
  562.  
  563.  
  564.         ' =========================================================
  565.         ' execute a program
  566.         '         IN : 1 = command-string
  567.         '         OUT: returncode of execution
  568.         ' =========================================================
  569.         ' this function is required for later impletations.
  570.         ' it is not in use at th moment.
  571.         function RUN(cmdstr)
  572.                 Dim result
  573.                 On Error Resume Next
  574.                 result = WSHShell.Run(cmdstr,0,true)
  575.                 if result>0 then
  576.                         MsgBox("Fehler bei Ausfⁿhren von <" & cmdstr & ">!!!")
  577.                         WScript.Quit result
  578.                 end if
  579.                 RUN=result
  580.         end function
  581.  
  582.  
  583. ' ========================================================================
  584. ' EOF ## info@axel-hahn.de | support@putzi4win.de
  585. ' ========================================================================
  586.