Willow37
Messages postés2Date d'inscriptionmardi 12 décembre 2000StatutMembreDernière intervention26 février 2009
-
26 févr. 2009 à 11:22
Willow37
Messages postés2Date d'inscriptionmardi 12 décembre 2000StatutMembreDernière intervention26 février 2009
-
26 févr. 2009 à 18:01
Bonjour,
je suis débutant en VBS et je souhaite remplacer le fichier host par un fichier host type
J'ai fait des commandes qui marchent a la main mais pas dans le script
Je souhaiterai soit copié le fichier a partir du VBS soit faire appel a un .bat qui s'occupera de faire la copie (la première solution étant plus pratique)
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 [file://\\chemin\hosts \\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="[file://chemin/copy.bat \\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