Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Delete Files in specified Folder write logfile on workstation and server.

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,63287
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Delete Files in specified Folder write logfile on workstation and server.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Delete Files in specified Folder write logfile on works... - 8/10/2008 12:04:33 PM   
  adamhaskins

 

Posts: 5
Score: 0
Joined: 8/7/2008
Status: offline
This script also writes a log file to a specified server telling you which computer the script ran on.
Deletes specific files based file location
Create log file on the computer the script runs on
Tell you when the file was deleted and also the last time it was deleted/modified.

'***** Notes:****************************************************************************************'*****************
'Initial release of script is 08/1/2008
'
'Created by: Adam Haskins
'
'Purpose: Delete E-POP Cached files in C:\tech to resolve license issue.
'
'Updates:
'
'*********************************************************************************************************************************
'
Dim MyFile, filesys, oLogFile, objName, strComp, nLogFile
Dim fso2, strText
Set filesys = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 8
Set oLogFile= filesys.OpenTextFile("COMPUTERSLOGFILEYOUWANTTOCREATE", ForAppending, True)
Set objName = CreateObject("WScript.NetWork")
' Set computer name of PC script is running on
strComp = objname.ComputerName
Set nLogfile = filesys.OpenTextFile("SERVER LOGFILELOCATION THAT YOU WANT TO CREATE" & strComp & ".txt", ForAppending, True)
REM Deletes Specific file 
 If filesys.FileExists("YOURFILENAMEANDLOCATION") Then 
 Set MyFile = filesys.GetFile("YOURFILENAMEANDLOCATION")
 oLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
 nLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
MyFile.Delete
end if
REM Deletes Specific File
If filesys.FileExists("YOURFILENAMEANDLOCATION") Then
 Set MyFile = filesys.GetFile("YOURFILENAMEANDLOCATION")
 oLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
 nLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
MyFile.Delete
end if
REM Deletes Specific file
 If Filesys.FileExists("YOURFILENAMEANDLOCATION") then
 Set MyFile = filesys.GetFile("YOURFILENAMEANDLOCATION")
 oLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
 nLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
MyFile.Delete
end if
REM Deletes Specific File
If Filesys.FileExists("YOURFILENAMEANDLOCATION") then
 Set MyFile = filesys.GetFile("YOURFILENAMEANDLOCATION")
 oLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
 nLogFile.writeLine(now & ": Deleted File " & myFile.shortname & " last modified " & MyFile.DateLastModified)
MyFile.Delete
end if
oLogFile.Close
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Delete Files in specified Folder write logfile on workstation and server. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts