none
how to delete Temp file and Prefetch files via Batch command without deleting, and creating again Temp folder, and Prefetch folder

    Question

  • i,m trying to clean temp files/ prefetch  files withe Batch command, without compliantly deleting and creating again this folders. In other words go to folder select everything in it, and delete also try not to get error "can't continue  this files are used by another program "

    this is wot i'm trying o avoid 

    @echo off
    COLOR 0A
    echo ..::TEMP ERASE::..
    ECHO.
    echo Regenerating "C:\Temp\" folder. . . 25%%
    echo Deleteing all files in folder...
    @echo on
    del /s /q c:\Temp\*
    @ping 127.0.0.1 -n 2 -w 100 > nul
    @ping 127.0.0.1 -n %1% -w 100> nul
    CLS

    @echo off
    echo ..::TEMP ERASE::..
    ECHO.
    echo Regenerating "C:\Temp\" folder. . . 50%%
    echo Creating new folder...
    @echo on
    rmdir /s /q c:\Temp\
    mkdir c:\Temp
    @ping 127.0.0.1 -n 2 -w 100 > nul
    @ping 127.0.0.1 -n %1% -w 100> nul
    CLS

    Thursday, December 01, 2011 9:03 PM

Answers

  • Hi,

     

    You may refer to the similar thread as below to check if the scripts help:

     

    BAT TO VBS

     

    Also, as this issue related with the scripts, it is recommended to submit your question on The Official Scripting Guys Forum.

     

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

     


    Sabrina

    TechNet Community Support

    • Marked as answer by Sabrina Shen Monday, December 12, 2011 3:51 AM
    Monday, December 05, 2011 9:56 AM

All replies

  • Ok this is what i have right now 

     

    %SystemRoot%\explorer.exe %temp%\

    pause

    del %temp%\*.*/s/q

    pause

    %SystemRoot%\explorer.exe C:\Windows\prefetch\

    pause

    del C:\Windows\prefetch\*.*/s/q

    pause

    it works, but it dos't delete some of the files, and leaves all of the folders intact in the %temp% folder. you alsow have to chous Yes or No Y/N 

    to conferm the delete. this kind of defeats purpose of Batch file commands

    so i tryed adding this to delete command ↓

     

    ECHO Y | del %temp%\*.*

     

    like it was suggested by this website  http://www.robvanderwoude.com/del.php
    it works but dos't delete all of the files all of the folders are left intact. so i have to [Shiift] + [A], [Shift] + [delete], [enter] every time
    please help me figure this out. I thing this will be useful . and Sorry for broken English
     

     



    Thursday, December 01, 2011 10:43 PM
  • Hi,

     

    You may refer to the similar thread as below to check if the scripts help:

     

    BAT TO VBS

     

    Also, as this issue related with the scripts, it is recommended to submit your question on The Official Scripting Guys Forum.

     

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

     


    Sabrina

    TechNet Community Support

    • Marked as answer by Sabrina Shen Monday, December 12, 2011 3:51 AM
    Monday, December 05, 2011 9:56 AM