1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Batch files for deleting

Discussion in 'Windows XP' started by wahlroot, 2004/03/02.

Thread Status:
Not open for further replies.
  1. 2004/03/02
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    In Win98SE I used the following Batch file (called "Clean ") to delete some files. It does not work with WinXP.

    @IF ERRORLEVEL 1 PAUSE
    @ECHO OFF

    DELTREE /y c:\temp\*.*
    DELTREE /y c:\*.chk
    DELTREE /y c:\windows\Cookies\*.txt
    DELTREE /y c:\windows\temp\*.*
    DELTREE /y c:\windows\Tempor~1\*.*
    DELTREE /y C:\windows\Locals~1\Tempor~1\*.*
    DELTREE /y C:\windows\Locals~1\Tempor~1\Cookie\*.txt
    DELTREE /y c:\PROGRA~1\Opera7\Cache4\*.*
    I know some of these files are in a different place on WinXP, but even if I change the location, it still does not work. Can someone help me. Also will any batch file remove folders, within a folder, as well as files. I am new to XP, so need any help I can get. Thanks.
     
    Last edited: 2004/03/02
  2. 2004/03/02
    goddez1

    goddez1 Inactive

    Joined:
    2002/01/12
    Messages:
    2,975
    Likes Received:
    49

  3. to hide this advert.

  4. 2004/03/02
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    I guess I am slow. I can not make del work. I am not sure folders I delete with rd will not come back and cause problems. Besides it does not seem to work with all folders. I am not clear what a line in the batch file should look like. So far I am going nowhere.
     
  5. 2004/03/02
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    The DELTREE command is not supported in windows 2000 or in windows xp.

    You must use the RDIR command as RD. (remove directory)

    You can use this in a batch file or a command file.

    Below is my batch file called cleanup.bat. Instructions are in the file itself because these folders cannot be deleted when explorer.exe is running. Change the directory path to your folders.

    @echo off
    echo.
    echo.
    echo Instructions:
    echo 1. Right click taskbar and select Task Manager.
    echo 2. Click Process Tab.
    echo 3. Right click EXPLORER.EXE and select End Process.
    echo 4. Click this window.
    echo 5. At prompt answer Y and press Enter key.
    echo 6. Repeat step 5.
    echo 7. Return to Task Manager, click File Menu and select New Task (Run...).
    echo 8. In Create New Task window type EXPLORER.EXE.
    echo 9. Press Enter key.
    echo 10. Close Task manager.
    @echo off
    RD /S "L:\Documents and Settings\TonyT\Local Settings\Temporary Internet Files "
    RD /S "L:\Documents and Settings\TonyT\Cookies "


    You can also use this in a command file (.CMD) as shown below. This is what I use now to delete these folders. It will auto kill explorer.exe, delete the folders and then restart explorer.exe. Note: If you have a running processes that is using the index.dat files then the folders will not get deleted. Some processes that hook into the index dat files are auto updates, scheduled tasks, and other apps that use the explorer shell, as well as some services like indexing service.

    If this cmd does not work for you then you must isolate what processes are dependant upon the index.dat files and kill them using similar lines in teh cmd file and restart them as well.

    Here's my cleanup.cmd file:

    taskkill /f /im explorer.exe
    RD /S/q "L:\Documents and Settings\TonyT\Local Settings\Temporary Internet Files "
    RD /S/q "L:\Documents and Settings\TonyT\Cookies "
    start explorer.exe


    This works on my system because my running processes are minimal and my system has any unneeded services either disabled or set to manual.

    re XP Supported Commands:
    Go into help and support, search for command-line
    Check out the command-line reference a-z
     
    Last edited: 2004/03/02
  6. 2004/03/04
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    I got back at it. Seems I did not put in the /s. Following is a line that does work.
    del /s/q "c:\PROGRA~1\Opera7\Profile\Cache4\*.* "
    Will do some more experimenting and see what happens. Thanks everyone for your help.
     
    Last edited: 2004/03/04
  7. 2004/03/05
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    Keep in mind that using *.* only deletes the files in a folder and some folders are best to delete entirely along with the index.dat files in those folders. Cookies and Temp Internet Files are an example of such folders. These folders will get recreated by windows.

    There has been much talk about index.dat files in these folders over the years. Most of it is hogwash, esp the stuff about ms spying on you etc etc. However, the index.dat files can grow very large and will often get corrupted, therefore it's good to delete them.

    Because index.dat files are system files, they will not get deleted when explorer.exe is running, thus is best to use a bat file or cmd file at startup, before windows loads completely, or manually kill explorer.exe from within windows and then execute the bat file.
     
  8. 2004/03/05
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    Thanks Tony, good to know about *.* I did delete cookies, but not index. I did use Autoexec.bat on 98SE, but I can not find it on XP. I do not know how to use a dat file on startup on XP.
     
    Last edited: 2004/03/05
  9. 2004/03/05
    Newt

    Newt Inactive

    Joined:
    2002/01/07
    Messages:
    10,974
    Likes Received:
    2
    wahlroot - XP does not normally run any autoexec file on startup. It has autoexec.nt and config.nt but they are only acivated when an older app that needs them is started. The .pif shortcut uses them.

    The process shown Here with some modifications looks like it might allow you to do what you want.
     
    Newt,
    #8
  10. 2004/03/06
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    Make your bat file and plave it in a directory.

    You can execute this file immediately after logon by entering the path in this regkey:

    The Userinit entry—The Userinit entry, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit, can also initiate programs when the system boots. You'll usually see an entry for userinit.exe, but this subkey can accept multiple comma-separated values (CSVs), so other programs can tack themselves onto the end of the entry.

    or these keys if exists on your system:

    The RunServicesOnce subkey—The RunServicesOnce subkey is designed to start service programs before the user logs on and before the other registry autostart subkeys start their programs. You'll find the RunServicesOnce subkey at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce and at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce.

    more about startup locations in the registry here:

    http://www.win2000mag.com/Windows/Article/ArticleID/27100/27100.html
     
  11. 2004/03/06
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    Learned something else today. I put ,C:\Clean Cache.bat after
    Userinit C:\Windows\system32\userinit.exe,C:\Clean Cache.bat and it Works on reboot, and shutdown and startup. Will keep the other lists of reg files for possible later use. May try more stuff in the bat file later. Do not like a lot of temp files hanging around. Thanks again.
     
    Last edited: 2004/03/06
  12. 2004/03/07
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    Very well done!
     
  13. 2004/03/19
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    Just when I think I have learned something here comes something else. I downloaded Powertoys and installed. Now I have hidden file autoexe.bat on my "C" drive. There is nothing in it. Checked Tweak UI and found under Logon, Parse Autoexec.bat at logon is checked. This does not show under msconfig. Does anyone know if this might cause problems, and could I use it to delete some temp files at logon without causing lockups. I have had 3 lockups, and had to delete and reinstall WinXP. No fun. I think this was caused by hardware install because it happened after. Is working now and want to keep it that way.
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.