1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| On Error Resume Next
Dim f
Set f = fso.GetFile("C:\WINDOWS\system32\drivers\etc\hosts")
Set WshShell=WScript.CreateObject("WScript.Shell")
set WshShell=CreateObject("WScript.Shell")
'Première solution
If Day(f.DateLastModified) < "26/02/2009 00:00:00" Then
strExec="XCOPY \\chemin\hosts C:\WINDOWS\system32\drivers\etc\hosts /Y"
strUser="/user:domain\user"
strPass="pass~"
strCmd="runas.exe " & strUser & " cmd"
WshShell.Run strCmd
WScript.Sleep 500
WshShell.SendKeys strPass
WshShell.Run strExec
Wscript.Quit
end if
'Deuxième solution
If Day(f.DateLastModified) < "26/02/2009 00:00:00" Then
strExec="\\chemin\copy.bat"
strUser="/user:domain\user"
strPass="pass~"
strCmd="runas.exe " & strUser & " " & strExec
WshShell.Run strCmd
WScript.Sleep 500
WshShell.SendKeys strPass
Wscript.Quit
end if |