Jump to content

Ddoan

Members
  • Posts

    2
  • Joined

  • Last visited

Reputation

0 Neutral

About Ddoan

Personal Information

  • Occupation
    IT
  • Location
    Colorado
  1. my update.... But running into problems with it not deleting everything in the My Pictures, My Videos, and My Music.... any suggestions? ****************** Dim sFileList() Dim oFolder Dim oFile Dim objFSO Dim sFileExtension Dim sMessage Dim objShell Dim strPath '// Run the cleanfolder function for the current directory i.e., desktop Set objShell = CreateObject ("WScript.Shell") sDesktop = objShell.SpecialFolders("Desktop") msgbox sDesktop CleanFolder sDesktop '// Run the cleanfolder function for My Documents sMyDocuments = objShell.SpecialFolders("MyDocuments") msgbox sMyDocuments CleanFolder sMyDocuments sub CleanFolder (sFolderName) Set objFSO = CreateObject ("Scripting.FileSystemObject") Set oFolder = objFSO.GetFolder(sFolderName) '// We are looping through all the files we found in the folder For Each oFile In oFolder.Files '// We are getting the file extension sFileExtension = Right(oFile.name, 3) '// We are checking if it is not a shortcut If sFileExtension <> "lnk" and sFileExtension <> "vbs" Then '// It's not a shortcut, so delete it 'oFile.Delete msgbox "We'll delete " & oFile.Name End IF '// Loop to the next file in the Files collection Next Set objSubFolder = oFolder.SubFolders For each oSubfolder in objSubFolder 's = oSubfolder.name & vbCrLf 'msgbox s 'oSubfolder.Delete msgbox "We'll delete " & oSubfolder.Name Next End sub
  2. I'm very new to scripting but at work my director challenged me with writing a script that would scrub the desktop and my documents for any file and folder and delete it, however it needs to keep the shortcuts on the desktop. I've peiced together some parts of other scripts I think do the job for the most part, but I need help understanding on how to exclude the .lnk files to be deleted... I was told that I would need to use an array and getfile function to make this work... please help! ***************** On Error Resume Next strPath = "c:\Documents and Settings\user\Desktop" Dim sCurrentDir Dim objShell Set objShell = CreateObject("Wscript.Shell") sCurrentDir = objShell.CurrentDirectory Function DeleteFolder(strFolderPath) Dim objFSO, objFolder Set objFSO = CreateObject ("Scripting.FileSystemObject") If objFSO.FolderExists(strFolderPath) Then objFSO.DeleteFolder strFolderPath, True End if Set objFSO = Nothing msgbox "Desktop Reset Complete." End Function
×
×
  • Create New...