Besitzer ermitteln

  • Hi,

    Ist es mit AutoIT möglich den Besitzer einer Datei (Verzeichnis) zu ermitteln?

    mfg

    *mow*

  • Probier mal das:

    Spoiler anzeigen
    [autoit]

    $sFile = @Scriptdir & "\reconnect.bat"

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("Besitzer: " & _GetExtProperty($sFile, 8) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]
  • Hallo,

    ich bin noch neu bei AutoIT und hab mich soweit bis jetzt ganz gut dsurchgearbeitet nun komm ich aber bei dem Besitzermitteln nicht weiter!
    Wie gebe ich denn den $sPath und $iProp richtig an.

    Egal wie ich es versuch es kommt immer ein fenster mit Besitzer: 0
    Ich möchte aber sehen wer der Besitzer ist!

    Wie geb ich das an, den Code hab ich so kopiert aber irgendwie komm ich nich damit klar!

  • Hi guten Morgen,

    meine BS ist Windows 7, das die eine Frage, und anbei ist der Code, aber ich denk ich bin da völlig falsch.
    Nur hab ich noch nich ganz verstanden wie ich die $sPath Variable mit der Datei deklariere. Ebenfalls die $iProp.

    Spoiler anzeigen
    [autoit]

    $sFile = @Scriptdir & "\test.bat"
    $sPath = "C:\test.txt"
    $iProp = "8"

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("Besitzer: " & _GetExtProperty($sFile, 8) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    sleep(5000);==>_GetExtProperty

    [/autoit]

    Hintergrund ist vielleicht auch nicht schlecht :D.
    ich habe 2 Standorte die über eine MPLS-Leitung verbunden sind! Jetzt hab ich an einer Stelle ein Programm mit einer Access Datenbank dahinter!
    Ich repliziere/spiegel die Daten zwischen den zwei Standorten, nun kann es zu Problemen kommen wenn auf einer Seite was geändert wird und auf der anderen Seite ebenfalls (zum gleichen Zeitpunkt).

    Die LDP Dateien die von Access beim Öffnen der Datenbank angelegt werden, werden aber nicht repliziert. bzw. würde es einfach auch zu lange dauern. Anschließend werden diese Daten wieder geschlossen.
    Nun hab ich schon ein Script geschrieben was die 2 Standorte nach der *.ldp Datei abfragt und je nachdem ob Sie vorhanden ist das Programm dann startet oder eine Meldung bringt das das Programm bereits gestartet ist!
    Das funktioniert auch ohne Probleme...

    Nun möchte ich aus der angelegt *.ldp Datei den Besitzer auslesen um in der Meldung den Nutzer, der die MS-Datenbank geöffnet hat mit anzuzeigen, so dass dort eine Kommunikation zwischen den jeweiligen Nutzern stattfinden kann.
    Die LDP datei wird ja von dem User angelegt und der Besitz übernommen der die Datenbank öffnet.

    Daher möchte ich dieses Skript nutzen, vielleicht hab ihr ja noch eine andere Idee an die ich noch gar nicht gedacht hab um dieses Problem sauber lösen zu können.

    Grüssle

    PS: die Nutzer haben unterschiedliche Betriebssysteme deswegen benötige ich natürlich was, was Systemübnergreifend funktioniert.

    2 Mal editiert, zuletzt von Reckl (12. Oktober 2010 um 07:31)

  • Hallo nochmal nach langem suchen hab ich es jetzt doch zusammen bekommen.
    Anbei dann der Code.

    Es ist tatsächlich so das unter WIndows 7 der Wert fü+r den besitzer 10 und nicht 8 wie bei Win XP ist.
    das ganze hab ich über ein Abfrage des aktuellen Betriebssystems mit dem das Programm gestartet wird gelöst! :)

    Anbei mein Code. Funktioniert auch ohne Probleme.

    Spoiler anzeigen
    [autoit]


    if @osbuild > 7000 Then
    $path = "[Pfad zur prüfenden Datei]"
    $prop = _GetExtProperty($path, 10)
    if FileExists("[Pfad zur prüfenden Datei]") Or FileExists("[Pfad zur prüfenden Datei]") Then
    Call ("_GetExtProperty")
    MsgBox(0, "[Programname]", "Sorry, aber das Programm ist bereits geöffnet, Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder nehmen Sie Kontakt mit dem folgenden Mitarbeiter auf: " & $prop)
    Else
    Run("[Programm]")
    EndIf
    ElseIf @osbuild < 7000 Then
    $path = "[Pfad zur prüfenden Datei]"
    $prop = _GetExtProperty($path, 8)
    if FileExists("[Pfad zur prüfenden Datei]") Or FileExists("[Pfad zur prüfenden Datei]") Then
    Call ("_GetExtProperty")
    MsgBox(0, "[Programname]", "Sorry, aber das Programm ist bereits geöffnet, Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder nehmen Sie Kontakt mit dem folgenden Mitarbeiter auf: " & $prop)
    Else
    Run("[Programm]")
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]


    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]

    Trotzdem vielen Dank für eure Hilfe. :)

    Gruß