Test Foro de elhacker.net SMF 2.1

Programación => Scripting => Mensaje iniciado por: elecktra en 27 Julio 2010, 17:13 PM

Título: Ayuda con VBS que borra archivos
Publicado por: elecktra en 27 Julio 2010, 17:13 PM
Estimados como estan?
necesito de su ayuda, hace tiepo em ayudaron con un script de VBS que lo que hace es borrar archivos con 1 mes de antiguedad, este es el codigo:

set objshell = createobject("wscript.shell")
objshell.run "cmd /c dir C:\pruebas /s /b > temp.txt",vbhide
wscript.sleep 2000
set objfso = createobject("scripting.filesystemobject")
set temp = objfso.opentextfile("temp.txt",1)
do until temp.atendofstream
fi = temp.readline
if objfso.fileexists(fi) = true then
if objfso.getfile(fi).parentfolder.name <> Registros then
if datediff("m",objfso.getfile(fi).datecreated,now()) >= 1 then
objfso.deletefile(objfso.getfile(fi).path)
end if
end if
end if
loop
temp.close


Lo que hace es escanear un directorio y losa rchivos con 1 mes de antiguedad lso elimina, lo que necesito es modificar el tiempo en vez de que sea1 mes necesito que lo elimine en 3 dias, sera posible?
ya que no entiendo VBS.
Gracias.
Título: Re: Ayuda con VBS que borra archivos
Publicado por: Novlucker en 27 Julio 2010, 17:18 PM
Código (vb,10) [Seleccionar]
set objshell = createobject("wscript.shell")
objshell.run "cmd /c dir C:\pruebas /s /b > temp.txt",vbhide
wscript.sleep 2000
set objfso = createobject("scripting.filesystemobject")
set temp = objfso.opentextfile("temp.txt",1)
do until temp.atendofstream
fi = temp.readline
if objfso.fileexists(fi) = true then
if objfso.getfile(fi).parentfolder.name <> Registros then
if datediff("d",objfso.getfile(fi).datecreated,now()) >= 3 then
objfso.deletefile(objfso.getfile(fi).path)
end if
end if
end if
loop
temp.close

Solo he cambiado la línea 10 :P

Saludos
Título: Re: Ayuda con VBS que borra archivos
Publicado por: elecktra en 27 Julio 2010, 17:33 PM
Se agradece amigo, muchas gracias.