Disable delete file in folder Temp

Discussion in 'Scripting' started by AhrimanSefid, Jan 28, 2013.

  1. AhrimanSefid

    AhrimanSefid MDL Junior Member

    Apr 12, 2010
    97
    0
    0
    Me Very Need Help For Disable delete file in folder.
    me run Babylon but close delete file and folder in temp me need help for copy file and folder make offline.
    Thanks A Lot.
     
  2. jayblok

    jayblok MDL Guru

    Dec 26, 2010
    3,142
    2,460
    120
    what did you say? you are trying to delete babylon? temp files/ toolbar? can you explain further? thank you
     
  3. AhrimanSefid

    AhrimanSefid MDL Junior Member

    Apr 12, 2010
    97
    0
    0
    I want to keep the babylon installation files in the temp and copy them to some other address, is there any solution for that.
     
  4. jayblok

    jayblok MDL Guru

    Dec 26, 2010
    3,142
    2,460
    120
    yes,go to search--> internet options--> settings--> move temp files to another address
    [​IMG]
     
  5. AhrimanSefid

    AhrimanSefid MDL Junior Member

    Apr 12, 2010
    97
    0
    0
    #5 AhrimanSefid, Jan 28, 2013
    Last edited: Jan 28, 2013
    (OP)
    Move Folder But Closed .Exe Delete All File And Folder.

    1.jpg
     
  6. wtarkan

    wtarkan MDL Member

    Sep 1, 2009
    144
    200
    10
    #6 wtarkan, Apr 3, 2013
    Last edited by a moderator: Apr 20, 2017
    just use that (.vbs)

    Code:
    '===DeleteTempFiles.vbs===
     'from velociraptor
    Const TemporaryFolder = 2 'for GetSpecialFolder
    set fso = createobject("scripting.filesystemobject")
    'init an empty array (ubound will be -1)...
    '
    'we use an array and store the file objects.
    'this avoids any problems with altering the
    'contents of the Files collections while they
    'are being iterated.
    '
    arFiles = array()
    count = -1
    'get the path to the temp folder
    '
    tempdir = fso.GetSpecialFolder(TemporaryFolder) 
    
    'load the (global scope) arFiles
    'SelectFiles calls itself recursively
    'for SubFolders
    '
    SelectFiles tempdir
    msgbox count+1 & " files found"
    'now do the actual deletes.  the error trap
    'is in case any are in-use...
    '
    dcount = 0
    for each file in arFiles
      on error resume next
      file.delete true
      if err.number = 0 then dcount = dcount + 1
      err.clear
      on error goto 0
    next
    'now go back and delete empty folders
    'below the temp folder
    DeleteEmptyFolders tempdir,false
    'comment out for "silent" operation,
    'or add support for a "/s" command-line switch.
    '
    msgbox count+1 & " files found, " & dcount & " deleted."
    sub SelectFiles(sPath)
      'select files to delete and add to array...
      '
      set folder = fso.getfolder(sPath)
      set files = folder.files
      for each file in files
        count = count + 1
        redim preserve arFiles(count)
        set arFiles(count) = file
      next
      for each fldr in folder.subfolders
        SelectFiles fldr.path
      next
    end sub
    sub DeleteEmptyFolders(sPath,bDeleteThisFolder)
      set folder = fso.getfolder(sPath)
      'recurse first...
      '
      for each fldr in folder.subfolders
        DeleteEmptyFolders fldr.path,true
      next
      'if no files or folders then delete...
      '
      'bDeleteThisFolder is false for
      'the root of the subtree, and true for
      'sub-folders (unless you want to delete
      'the entire subtree if it is empty).
      '
      if (folder.files.count = 0) and _
         (folder.subfolders.count) = 0 and _
         bDeleteThisFolder then
        folder.delete
        exit sub
      end if
    end sub
    '
    '===script-sonu=== 
     
  7. spencer09

    spencer09 MDL Novice

    Sep 18, 2013
    19
    1
    0
    That's it .Thanks ,i came across the same problem .
     
  8. Dos_Probie

    Dos_Probie MDL Senior Member

    Jul 18, 2012
    250
    84
    10
    #8 Dos_Probie, Oct 19, 2013
    Last edited by a moderator: Apr 20, 2017
    aio temp cleanup..

    I know this is a old thread, but here is what I use for my UA Installs and it runs silent without any prompting..DP:biggrin:

    Code:
    'Flush and Remove all "in use-locked" files from temp..
    Option Explicit
    Dim objShell
    Dim objSysEnv,objUserEnv
    Dim strUserTemp
    Dim strSysTemp
    Dim userProfile,TempInternetFiles
    Dim OSType
    Set objShell=CreateObject("WScript.Shell")
    Set objSysEnv=objShell.Environment("System")
    Set objUserEnv=objShell.Environment("User")
    strUserTemp= objShell.ExpandEnvironmentStrings(objUserEnv("TEMP"))
    strSysTemp= objShell.ExpandEnvironmentStrings(objSysEnv("TEMP"))
    userProfile = objShell.ExpandEnvironmentStrings("%userprofile%")
    DeleteTemp strUserTemp 'delete user temp files
    DeleteTemp strSysTemp  'delete system temp files
     'delete Internet Temp files
     'the Internet Temp files path is diffrent according to OS Type
    OSType=FindOSType
    If OSType="Windows 7" Or OSType="Windows Vista" Then
    TempInternetFiles=userProfile & "\AppData\Local\Microsoft\Windows\Temporary Internet Files"
    ElseIf  OSType="Windows 2003" Or OSType="Windows XP" Then
    TempInternetFiles=userProfile & "\Local Settings\Temporary Internet Files"
    End If
    DeleteTemp TempInternetFiles
    'this is also to delete Content.IE5 in Internet Temp files
    TempInternetFiles=TempInternetFiles & "\Content.IE5"
    DeleteTemp TempInternetFiles
    WScript.Quit
    Sub DeleteTemp (strTempPath)
    On Error Resume Next
    Dim objFSO
    Dim objFolder,objDir
    Dim objFile
    Dim i
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFolder=objFSO.GetFolder(strTempPath)
    'delete all files
    For Each objFile In objFolder.Files
    objFile.delete True
    Next
    'delete all subfolders
    For i=0 To 10
     For Each objDir In objFolder.SubFolders
     objDir.Delete True
     Next
    Next
    
    'clear all objects
    Set objFSO=Nothing
    Set objFolder=Nothing
    Set objDir=Nothing
    Set objFile=Nothing
    End Sub
    Function FindOSType
        'Defining Variables
        Dim objWMI, objItem, colItems
        Dim OSVersion, OSName
      Dim ComputerName
      
      ComputerName="."
      
        'Get the WMI object and query results
        Set objWMI = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
        Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)
     
        'Get the OS version number (first two) and OS product type (server or desktop) 
        For Each objItem in colItems
            OSVersion = Left(objItem.Version,3)
                    
        Next
     
        
        Select Case OSVersion
            Case "6.1"
             OSName = "Windows 7"
            Case "6.0" 
                OSName = "Windows Vista"
            Case "5.2" 
                OSName = "Windows 2003"
            Case "5.1" 
                OSName = "Windows XP"
            Case "5.0" 
                OSName = "Windows 2000"
       End Select
     
        'Return the OS name
        FindOSType = OSName
        
        'Clear the memory
        Set colItems = Nothing
        Set objWMI = Nothing
    End Function