Jump to content
Sign in to follow this  
timyboy

DLL search and register autom.

Recommended Posts

timyboy

Is there a UDF which automatically in a folder and subfolders for. DLL is located and if already present renewed?

Share this post


Link to post
Share on other sites
timyboy

RequireAdmin
IsAdmin()
#include-once
#include <Date.au3>
#include <Array.au3>
#include <File.au3>
#include <DateTimeConstants.au3>


Global $sFile,$tFile,$tPath

If @OSArch = "64" Then $tPath = "\%Systemroot%\System32\" ;Die 64-Bit-Version ist
If @OSArch = "86" Then $tPath = "\%Systemroot%\SysWoW64\" ;Die 32-Bit-Version ist

Global $sPath = @ScriptDir
Global $hSearch = FileFindFirstFile($sPath & "\*.dll")
Global $tSearch = FileFindFirstFile($tPath & "\*.dll")

If $hSearch = -1 Then
    TrayTip("Info", "Keine neuen DLLs enthalten !  ", 5, 1)
    Sleep(1250)
    TrayTip("clears any tray tip", "", 0)
    Exit
EndIf

While True
    $sFile = FileFindNextFile($hSearch)
    If @error Then ExitLoop
    $tFile = FileFindNextFile($tSearch)
    If @error Then _Neu()
    _Version()
    ExitLoop
WEnd

Func _Neu()
    FileCopy($sFile , $tPath, 9)
    Sleep(50)
    ShellExecute("regsvr32.exe" & '/s' , "'" & $tPath & "\" & $sFile &  "'")
    ConsoleWrite("Dll registriert: " & $sFile & @CRLF)
    Sleep(50)
    Exit
EndFunc

Func _Version()

Local $Fileversion1 = FileGetVersion($hSearch, 1)
If @error Then _Time()
Local $Fileversion2 = FileGetVersion($tSearch, 1)
If @error Then _Time()

If $Fileversion1 > $Fileversion2 Then
    FileDelete($Fileversion2)
    Sleep(50)
    FileCopy($Fileversion1 , $Fileversion2, 9)
    Sleep(50)
    ShellExecute("regsvr32.exe" ,  ' /s '  & $tPath & "\" & $tFile &  "'")
    ConsoleWrite("Dll registriert: " & $tFile & @CRLF)
    Sleep(50)
Else
    FileDelete($Fileversion1)
    Sleep(50)
    ConsoleWrite("KEINE Dll registriert: " & $tFile & @CRLF)
    Sleep(50)
Endif

EndFunc

Func _Time()

Local $File1 = FileGetTime($hSearch, 1)
Local $File2 = FileGetTime($tSearch, 1)

If Not @error Then
    If $File1[0]>$File2[0] or $File1[1]>$File2[1] or $File1[2]>$File2[2] or $File1[3]>$File2[3] or $File1[4]>$File2[4] then ; mit [5] haste auch noch die Sekunden ;)
        FileDelete($File2) ;oder du machst FileCopy und mit dem flag das er es überschreiben soll ;-) FileCopy("Pfad wo es jetzt liegt", "Pfadwo es hin soll",1) die 1 heisst überschreiben
        Sleep(50)
        FileCopy($File1, $File2, 9)
        Sleep(50)
        ShellExecute("regsvr32.exe",  ' /s ' & $tPath & "\" & $tFile & "'")
        ConsoleWrite("Dll registriert: " & $tFile & @CRLF)
        TrayTip("Info", "Dll registriert: " & $tFile & @CRLF , 5, 1)
        Sleep(2500)
        TrayTip("clears any tray tip", "", 0)
        Sleep(50)
   Else
        FileDelete($File1)
        Sleep(50)
        ConsoleWrite("KEINE Dll registriert: " & $tFile & @CRLF)
        TrayTip("KEINE Dll registriert:", "$tFile & @CRLF "  , 5, 1)
        Sleep(2500)
        TrayTip("clears any tray tip", "", 0)
        Sleep(50)
   Endif
EndIf
;$Filex[0] = year (four digits)    x steht für die jeweilige Zahl ;)
;$Filex[1] = month (range 01 - 12)
;$Filex[2] = day (range 01 - 31)
;$Filex[3] = hour (range 00 - 23)
;$Filex[4] = min (range 00 - 59)
;$Filex[5] = sec (range 00 - 59)
EndFunc

Share this post


Link to post
Share on other sites
timyboy

Where is the error because the DLL will always new regestriert, although this should happen only in newer versions.

Share this post


Link to post
Share on other sites
timyboy

I habe problems with  ShellExecute("regsvr32.exe" & '/s' , "'" & $tPath & "" & $sFile &  "'")

what is wrong?

Share this post


Link to post
Share on other sites
AZJIO

MsgBox(0, '', @OSArch)

'x64' = '64' ?

'x86' = '86' ?

You can check variables?

 

better?

 

$tPath = ';)'
If @OSArch = "64" Then 
    $tPath = "\%Systemroot%\System32\" ;Die 64-Bit-Version ist
Else    
If @OSArch = "86" Then 
    $tPath = "\%Systemroot%\SysWoW64\" ;Die 32-Bit-Version ist
EndIf
EndIf
MsgBox(0, 'O_o', $tPath)
Edited by AZJIO

Share this post


Link to post
Share on other sites
timyboy

Ok, thanks. And now i have problems with the regsvr32. And a dll is registered to be tried again and again, although this is not new.

#RequireAdmin
IsAdmin()
#include-once
#include <Date.au3>
#include <Array.au3>
#include <File.au3>
#include <DateTimeConstants.au3>


Global $sFile,$tFile,$tPath
Global $sPath = @ScriptDir
Global $hSearch = FileFindFirstFile($sPath & "\*.dll")
Global $tSearch = FileFindFirstFile($tPath & "\*.dll")


If @OSArch = "64" Then
    $tPath = "\%Systemroot%\System32\" ;Die 64-Bit-Version ist
Else
If @OSArch = "86" Then
    $tPath = "\%Systemroot%\SysWoW64\" ;Die 32-Bit-Version ist
EndIf
EndIf



If $hSearch = -1 Then
    TrayTip("Info", "Keine neuen DLLs enthalten !  ", 5, 1)
    Sleep(1250)
    TrayTip("clears any tray tip", "", 0)
    Exit
EndIf

While True
    $sFile = FileFindNextFile($hSearch)
    If @error Then ExitLoop
    $tFile = FileFindNextFile($tSearch)
    If @error Then _Neu()
    _Version()
    ExitLoop
WEnd

Func _Neu()
    FileCopy($sFile , $tPath, 9)
    Sleep(50)
    ShellExecute("regsvr32.exe" , "'" & $tPath & "\" & $sFile &  "'")
    ConsoleWrite("Dll registriert: " & $sFile & @CRLF)
    Sleep(50)
    Exit
EndFunc

Func _Version()

Local $Fileversion1 = FileGetVersion($hSearch, 1)
If @error Then _Time()
Local $Fileversion2 = FileGetVersion($tSearch, 1)
If @error Then _Time()

If $Fileversion1 > $Fileversion2 Then
    FileDelete($Fileversion2)
    Sleep(50)
    FileCopy($Fileversion1 , $Fileversion2, 9)
    Sleep(50)
    ShellExecute("regsvr32.exe" ,  ' /s '  & $tPath & "/" & $tFile &  "'")
    ConsoleWrite("Dll registriert: " & $tFile & @CRLF)
    Sleep(50)
Else
    FileDelete($Fileversion1)
    Sleep(50)
    ConsoleWrite("KEINE Dll registriert: " & $tFile & @CRLF)
    Sleep(50)
Endif

EndFunc






Func _Time()

Local $File1 = FileGetTime($hSearch, 1)
Local $File2 = FileGetTime($tSearch, 1)

If Not @error Then
    If $File1[0]>$File2[0] or $File1[1]>$File2[1] or $File1[2]>$File2[2] or $File1[3]>$File2[3] or $File1[4]>$File2[4] then ; mit [5] haste auch noch die Sekunden ;)
        FileDelete($File2) ;oder du machst FileCopy und mit dem flag das er es überschreiben soll ;-) FileCopy("Pfad wo es jetzt liegt", "Pfadwo es hin soll",1) die 1 heisst überschreiben
        Sleep(50)
        FileCopy($File1, $File2, 9)
        Sleep(50)
        ShellExecute("regsvr32.exe",  "'" & $tPath & "\" & $tFile & "'")
        ConsoleWrite("Dll registriert: " & $tFile & @CRLF)
        TrayTip("Info", "Dll registriert: " & $tFile & @CRLF , 5, 1)
        Sleep(2500)
        TrayTip("clears any tray tip", "", 0)
        Sleep(50)
   Else
        FileDelete($File1)
        Sleep(50)
        ConsoleWrite("KEINE Dll registriert: " & $tFile & @CRLF)
        TrayTip("KEINE Dll registriert:", "$tFile & @CRLF "  , 5, 1)
        Sleep(2500)
        TrayTip("clears any tray tip", "", 0)
        Sleep(50)
   Endif
EndIf
;$Filex[0] = year (four digits)    x steht für die jeweilige Zahl ;)
;$Filex[1] = month (range 01 - 12)
;$Filex[2] = day (range 01 - 31)
;$Filex[3] = hour (range 00 - 23)
;$Filex[4] = min (range 00 - 59)
;$Filex[5] = sec (range 00 - 59)
EndFunc
 
Edited by timyboy

Share this post


Link to post
Share on other sites
AZJIO

I started to do it, but I got confused and tired.

#RequireAdmin
IsAdmin()
#include-once
#include <Date.au3>
#include <Array.au3>
#include <File.au3>
#include <DateTimeConstants.au3>

Global $sFile, $tFile, $SysPath

Global $SysPath
If @OSArch = 'x64' Then
    $SysPath = @HomeDrive '\System32' ;Die 64-Bit-Version ist
Else
    $SysPath = @HomeDrive '\SysWoW64' ;Die 32-Bit-Version ist
EndIf

Global $sPath = @ScriptDir
; Global $hSearch = FileFindFirstFile($sPath & "\*.dll")
; Global $tSearch = FileFindFirstFile($SysPath & "\*.dll")

$aSysFile = _FileListToArray($SysPath, "*.dll", 1)
$aCurFile = _FileListToArray($sPath, "*.dll", 1)
If @error Then
    ; If $hSearch = -1 Then
    TrayTip("Info", "Keine neuen DLLs enthalten !  ", 5, 1)
    Sleep(1250)
    TrayTip("clears any tray tip", "", 0)
    Exit
EndIf

While True
    ; $sFile = FileFindNextFile($hSearch)
    ; If @error Then ExitLoop
    ; $tFile = FileFindNextFile($tSearch)
    For $i = 1 To $aCurFile[0]
        If Not FileExists($SysPath & "\" & $aCurFile[$i]) Then _Neu($i)
    Next
    ; If @error Then _Neu()
    _Version()
    ExitLoop
WEnd

Func _Neu($i)
    FileCopy($sPath & "\" & $aCurFile[$i], $SysPath & "\" & $aCurFile[$i], 9)
    Sleep(50)
    ; ShellExecute('regsvr32.exe /s', $SysPath & "\" & $aCurFile[$i])
    MsgBox(0, 'Yes?', 'regsvr32.exe /s ' & $SysPath & '\' & $aCurFile[$i])
    RunWait('regsvr32.exe /s ' & $SysPath & '\' & $aCurFile[$i])
    ConsoleWrite("Dll registriert: " & $sFile & @CRLF)
    Sleep(50) ; ???
    Exit ; ??? But what about the rest of the files? let them go down to the woods?
EndFunc   ;==>_Neu

Share this post


Link to post
Share on other sites
BrewManNH

syntax error

Could you be any more vague than this?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×