Bonjour,
Pour changer la date, il faut opérer "as Administrator"
Je n'ai rien trouvé de mieux que passer par un fichier ... mais ça fonctionne ...
Si on recule de un jour avec -1, pour revenir, il faut utiliser +1.
Sujet à amélioration ...
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Sub test()
Dim nouvelledate As Date
nouvelledate = DateSerial(Year(Date), Month(Date), Day(Date)) - 1
Close
chemin = "C:\Madate\"
Open chemin & "LaDate.cmd" For Output As #1
Print #1, "date " & nouvelledate
Close
ShellExecute 0, "runas", chemin & "ladate.cmd", Command & "/admin", vbNullString, SW_SHOWNORMAL
End Sub
Gelinotte