Posts: 48
Threads: 11
Joined: Jun 2022
Reputation:
0
Hello everyone,
Can someone suggest the code to change the creation date, last access date, and modification date of a file?
I believe it requires calls to KERNEL32 but I'm not sure how to do it.
Thank you!
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
Last Access Date and Last Modified Date should be able to be changed by simply opening and re-saving the file. It's a pretty simple Google search for the other.
Tread on those who tread on you
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
$(Get-Item myfile.ext).creationtime=$(Get-Date "mm/dd/yyyy")
$(Get-Item myfile.ext).lastaccesstime=$(Get-Date "mm/dd/yyyy")
$(Get-Item myfile.ext).lastwritetime=$(Get-Date "mm/dd/yyyy")
^ Powershell method to change all 3 in Windows.
Just SHELL with the proper substitutions and you should be golden.
Posts: 48
Threads: 11
Joined: Jun 2022
Reputation:
0
Thank you, SMcNeill, using the Powershell command was not as straightforward as expected but it worked perfectly in the end.
The suggested SpriggsySpriggs system is a classic example of "lateral thinking" which always has a certain charm! However, certain files cannot be processed in that way without compromising them.
The correct version, in my case, of the SHELL code is similar to the following:
___________
file$ = "C:\provax\provax.pdf"
nuovadata$ = "18/12/2021 08:00"
SHELL _hide "powershell $(Get-Item '" + file$ + "' ).creationtime=$(Get-Date '"+ nuovadata$ +"')"
SHELL _hide "powershell $(Get-Item '" + file$ + "' ).lastaccesstime=$(Get-Date '"+ nuovadata$ +"')"
SHELL _hide "powershell $(Get-Item '" + file$ + "' ).lastwritetime=$(Get-Date '"+ nuovadata$ +"')"
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
I'd recommend adding -NoProfile to your PowerShell calls. This speeds up the call by dropping any unnecessary user preferences that PowerShell tries to load.
Tread on those who tread on you