Komisches Windows-Problem mit FileSetTime

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Komisches Windows-Problem mit FileSetTime

13 Jul 2016, 05:40

Zvonko wrote:@nnnik: Heißt das, dass du mit meinem ursprünglichen Demo-Skript bei dir das Problem nicht siehst?
Nein ich habe dieses Verhalten nicht. (Win 8.1 64)
Recommends AHK Studio
just me
Posts: 9511
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Komisches Windows-Problem mit FileSetTime

14 Jul 2016, 04:47

Moin Zvonko,

ich habe noch weiter herumgespielt und kann das Problem jetzt auch nachstellen. Hier gibt es einen Beitrag von barryd815 mit einem interessanten Hinweis, der möglicherweise in Deinem Fall als Workaround genutzt werden kann. Danach nutzen auch das mit Win Vista eingeführte Property System und/oder der Property Handler und/oder der Indexdienst ADS Streams für die Ablage bestimmter Merkmale. Die von Dir erzeugten EML-Dateien haben keinen solchen Stream. Er wird deshalb neu angelegt, wenn die Datei erstmalig im Explorer angefasst/angezeigt wird. Dadurch wird dann das Änderungsdatum der Datei aktualisiert.

Ich weiß nicht, welche Informationen dort abgelegt sind und wofür sie gebraucht werden. Es kann aber möglichertweise in Deinem Fall als Workaround genutzt werden, wenn Du der EML-Datei auch einen leeren ADS spendierst. Das Änderungsdatum wird dann vom Explorer anscheinend nicht mehr verändert:

Code: Select all

#NoEnv

Dat := 20000101010000

EmlDir := A_ScriptDir
EmlFile := "FileEml.eml"
EmlPath := EmlDir . "\" . EmlFile


FileDelete, %EmlPath%
FileAppend, , %EmlPath%
FileAppend, , %EmlPath%:OECustomProperty

; Run, Properties %EmlPath%		; WITHOUT THIS PART
; WinWait, ahk_class #32770		; OF THE SCRIPT
; Send {Esc}						; WINDOWS REVOKES
; WinWaitClose					; THE SUBSEQUENT CHANGES MADE TO THE MODIFICATION TIME OF EML FILES

FileSetTime, %Dat%, %EmlPath%, C
FileSetTime, %Dat%, %EmlPath%, A
FileSetTime, %Dat%, %EmlPath%, M


FileGetTime, TimeEml, %EmlPath%, M

MsgBox The modification time of the files has been changed to Jan 1 2000.`r`nFileGetTime confirms this:`r`nEml: %TimeEml%

MsgBox Check now (after closing this MsgBox) the properties of the file.`r`nIs the modification time of the EML file changed as desired?

Run, *Explore %EmlDir%
Ob das sonst wo negative Auswirkungen hat, musst Du ggf. selbst herausfinden.
Zvonko
Posts: 210
Joined: 19 Jun 2015, 11:52

Re: Komisches Windows-Problem mit FileSetTime

14 Jul 2016, 05:54

@just me:

GENIAL ... WIE IMMER!!!

Mit den alten Diskussionen habe ich mich auch beschäftigt, auch den Beitrag von barryd815 habe ich gelesen, der Tipp war aber für mich nicht in AHK umsetzbar. (Wo in der AHK-Dokumentation ist dieses angehängte ':' bei FileAppend erwähnt?)

Die Auswirkung deiner Lösung ist allerdings "minimal": Deine Lösung ist "nur" ca. SECHS MAL schneller als mein stümperhaftes Workaround! :clap:

Negative Auswirkungen sehe ich bisher nicht.
For me as a newbie it is frustrating to fail due to "little" problems in projects in which the entire concept and even complex functions are working perfectly...
just me
Posts: 9511
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Komisches Windows-Problem mit FileSetTime

14 Jul 2016, 07:58

Hallo Zvonko,

ich weiß nicht, ob sich in der AHK-Doku Hinweise zu ADS finden, glaube es aber eher nicht. Am Anfang hat Microsoft ja versucht, das Ganze möglichst unter dem Tisch zu halten.

Soweit ich mich erinnere, war mein erster Kontakt im Zusammenhang mit AHK das 'versteckte' Einbetten von INI-Files in Skripte als Scipt.ahk:INI.

AHK kann jedenfalls damit umgehen, und das ist zumindest in diesem Fall auch gut so. ;)
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Komisches Windows-Problem mit FileSetTime

14 Jul 2016, 08:32

@just me

Mehr Infos dazu (Scipt.ahk:INI) bitte =)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9511
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Komisches Windows-Problem mit FileSetTime

14 Jul 2016, 08:51

:offtopic:

Moin jNizM,

Code: Select all

#NoEnv
IniFile := A_ScriptFullPath . ":INI"
IniWrite, %IniFile%, %IniFile%, Main, Path
IniRead, Path, %IniFile%, Main, Path
MsgBox, 0, IniRead, %Path%
FileRead, Content, %IniFile%
MsgBox, 0, FileRead, %Content%
ExitApp
Funktioniert nur mit NTFS. Bei Kopieren nach FAT oder sonstigen Dateisystemen geht der INI-Teil der Datei verloren.

Änderungen der INI ändern wie bei Zvonko das Änderungsdatum der Skriptdatei. Wenn Du das verbergen willst, musst Du Dir das Änderungsdatum der Skriptdatei vor dem Schreiben holen und anschließend wieder zurücksetzen.

Du solltest vielleicht auch im alten deutschen Forum etwas dazu finden können.
Johnny R
Posts: 348
Joined: 03 Oct 2013, 02:07

Re: Komisches Windows-Problem mit FileSetTime

15 Jul 2016, 07:39

Interessant, die Sache mit dem "Alternative Data Stream" (ADS) auf NTFS! Hier gibt es einige interessante Software dazu:
Streams von Sysinternals
AlternateStreamView von NirSoft
ADSManager von DmitryBrant
Mit einigen Editoren kann man ADS-Streams direkt editieren. Mit meinem UltraEdit32 geht es zum Beispiel (s. u.). Mit Notepad geht es nicht, es sei denn der Stream hat eine Dateiendung. Andere Tools lassen nur einen Export mit anschließendem Editieren zu.

Image
just me
Posts: 9511
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Komisches Windows-Problem mit FileSetTime

16 Jul 2016, 04:51

:offtopic:

Moin Johnny R,

zumindest ab Win Vista kann man sich das auch selbst anschauen:

Code: Select all

#NoEnv
SetBatchLines, -1

FileName := "Fully qualified file name"
For Index, Stream In EnumFileStreams(FileName)
   MsgBox, 0, Stream #%Index%, % "Size: " . Stream.Size . "`nName: " . Stream.Name

EnumFileStreams(FileName) { ; msdn.microsoft.com/en-us/library/aa364424(v=vs.85).aspx
   ; FileName : The fully qualified file name.
   Streams := []
   If (DllCall("GetVersion", "UChar") < 6) ; requires Vista+ (not sure about this)
      Return False
   VarSetCapacity(FSD, 600, 0) ; WIN32_FIND_STREAM_DATA
   HFIND := DllCall("FindFirstStreamW", "WStr", FileName, "Int", 0, "Ptr", &FSD, "UInt", 0, "Ptr")
   If (HFIND <> -1) {
      ; Uncomment to add the main stream of the file (i.e. the file itself)
      ; Streams.Insert({Size: NumGet(&FSD, 0, "UInt64"), Name: StrGet(&FSD + 8, 296, "UTF-16")})
      While DllCall("FindNextStreamW", "Ptr", HFIND, "Ptr", &FSD)
         Streams.Insert({Size: NumGet(&FSD, 0, "UInt64"), Name: StrGet(&FSD + 8, 296, "UTF-16")})
      DllCall("FindClose", "Ptr", HFIND)
      Return Streams
   }
   Return False
}
Das Editieren ist etwas problematischer. Man muss ja wissen, was drinsteht. Im Fall von :OECustomProperty (s.o.) sind das anscheinend Binärwerte, über deren Bedeutung ich nichts gefunden habe.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 30 guests