jaja714 Posted February 25, 2021 Share Posted February 25, 2021 Am I correct in assuming AutoIt cannot alter the creation timestamp of a windows file for security reasons? i'm trying to FileCopy (and rename) thousands of spreadsheets to a new directory but I want to keep the file times. FileSetTime works great for modified and accessed date but not for create date. If this is a security violation, I suppose I can start over and use robocopy or something. Link to comment Share on other sites More sharing options...
Musashi Posted February 25, 2021 Share Posted February 25, 2021 (edited) 1 hour ago, jaja714 said: Am I correct in assuming AutoIt cannot alter the creation timestamp of a windows file for security reasons? As far as I can tell, No . Take a look at _Date_Time_SetFileTime I copied a file to another directory and was able to restore the original creation timestamp. Edited February 25, 2021 by Musashi typo "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
jaja714 Posted February 25, 2021 Author Share Posted February 25, 2021 Unfortunately, _Date_Time_SetFileTime, needs a filehandle and, since I already copied the files not knowing about this alternate version of FileSetTime, _Date_Time_SetFileTime does not seem to be an option for me. Link to comment Share on other sites More sharing options...
TheXman Posted February 25, 2021 Share Posted February 25, 2021 (edited) FileSetTime, with $FT_CREATED, sets the create date just fine on my machine. I just tested it on a Win7 box. So if it doesn't work for you, then maybe there's an issue in your environment or your implementation. Since you haven't shown the relevant code that you are using, it's REALLY hard to know why it may not be working for you. Edited February 25, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
jaja714 Posted February 25, 2021 Author Share Posted February 25, 2021 Maybe it is the fact that the files reside on a network share or something. No worries, I just put the create timestamp in the actual filename as a workaround. Link to comment Share on other sites More sharing options...
Musashi Posted February 25, 2021 Share Posted February 25, 2021 27 minutes ago, TheXman said: FileSetTime, with $FT_CREATED, sets the create date just fine on my machine. Yes, I can confirm that (for the sake of completeness only ). It is also easier to handle compared to _Date_Time_SetFileTime. TheXman 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Musashi Posted February 25, 2021 Share Posted February 25, 2021 44 minutes ago, jaja714 said: Unfortunately, _Date_Time_SetFileTime, needs a filehandle ... To get the handle(s) of the respective file(s) you can use _WinAPI_CreateFile . The function name (...CreateFile) is a bit misleading, because with the parameter $iCreation=2 an already existing file can be opened. By using the parameter $iAccess=4 the timestamps can be inserted. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now