.BAT program issue

Discussion in 'General Software' started by scorps65, Jul 18, 2008.

  1. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    In 2006, i created a very simple .BAT program to delete cookies, temporary files and so on....
    I uploaded this 19kb .BAT file to DOWNLOAD.COM and got a 4 out of 5 from CNET and the same from a user!
    Good news no? NOT REALLY. I got 2 users saying it deleted they're documents and all sorts of things!
    Of course, they gave me a 1 out of 5 and lowered my score. It works fine on my pc though...

    The questions is, i need someone who understands Command Prompt language and help me fix this error. Why does it delete absolutely everything on ones computer but work fine on another? Here's a sample of code from where the error seems to occur (Removing Junk Files)

    Code:
    ECHO                               Removing Junk Files
    
    ECHO.
    
    PING 127.0.0.1 /n 2 /w 1000 > NUL
    
    TASKKILL /F /IM wdfmgr.exe
    
    CD\
    CD %ALLUSERSPROFILE%\Application Data\Microsoft\Dr Watson\
    IF NOT EXIST "%ALLUSERSPROFILE%\Application Data\Microsoft\Dr Watson\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %ALLUSERSPROFILE%\Application Data\Microsoft\Media Index\
    IF NOT EXIST "%ALLUSERSPROFILE%\Application Data\Microsoft\Media Index\" GOTO CD\
    DEL wmplibrary_v_0_12.db /Q
    
    :CD\
    CD %ALLUSERSPROFILE%\Application Data\Microsoft\MSDAIPP\Offline\
    IF NOT EXIST "%ALLUSERSPROFILE%\Application Data\Microsoft\MSDAIPP\Offline\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\
    IF NOT EXIST "%SYSTEMROOT%\schedlgu.txt" GOTO CD\
    DEL schedlgu.txt /Q
    
    :CD\
    CD %SYSTEMROOT%\Debug\
    IF NOT EXIST "%SYSTEMROOT%\Debug\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\Downloaded Installations\
    IF NOT EXIST "%SYSTEMROOT%\Downloaded Installations\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\Downloaded Program Files\
    IF NOT EXIST "%SYSTEMROOT%\Downloaded Program Files\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\Minidump\
    IF NOT EXIST "%SYSTEMROOT%\Minidump\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\msdownld.tmp\
    IF NOT EXIST "%SYSTEMROOT%\msdownld.tmp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\PCHEALTH\HELPCTR\Config\Cache\
    IF NOT EXIST "%SYSTEMROOT%\PCHEALTH\HELPCTR\Config\Cache\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\PCHEALTH\HELPCTR\Logs\
    IF NOT EXIST "%SYSTEMROOT%\PCHEALTH\HELPCTR\Logs\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\PCHEALTH\HELPCTR\OfflineCache\
    IF NOT EXIST "%SYSTEMROOT%\PCHEALTH\HELPCTR\OfflineCache\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\PCHEALTH\HELPCTR\Temp\
    IF NOT EXIST "%SYSTEMROOT%\PCHEALTH\HELPCTR\Temp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\Prefetch\
    IF NOT EXIST "%SYSTEMROOT%\Prefetch\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\Cache\
    IF NOT EXIST "%SYSTEMROOT%\system32\Cache\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\config\systemprofile\Cookies\
    IF NOT EXIST "%SYSTEMROOT%\system32\config\systemprofile\Cookies\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\config\systemprofile\Local Settings\History\
    IF NOT EXIST "%SYSTEMROOT%\system32\config\systemprofile\Local Settings\History\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\config\systemprofile\Local Settings\Temp\
    IF NOT EXIST "%SYSTEMROOT%\system32\config\systemprofile\Local Settings\Temp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\config\systemprofile\Local Settings\Temporary Internet Files\
    IF NOT EXIST "%SYSTEMROOT%\system32\config\systemprofile\Local Settings\Temporary Internet Files\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\config\systemprofile\Recent\
    IF NOT EXIST "%SYSTEMROOT%\system32\config\systemprofile\Recent\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\wbem\Logs\
    IF NOT EXIST "%SYSTEMROOT%\system32\wbem\Logs\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\Temp\
    IF NOT EXIST "%SYSTEMROOT%\Temp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Application Data\Microsoft\Office\Recent\
    IF NOT EXIST "%USERPROFILE%\Application Data\Microsoft\Office\Recent\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\file\
    IF NOT EXIST "%USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\file\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\jar\
    IF NOT EXIST "%USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\jar\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\tmp\
    IF NOT EXIST "%USERPROFILE%\Application Data\Sun\Java\Deployment\cache\javapi\v1.0\tmp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Application Data\Sun\Java\Deployment\cache\tmp\
    IF NOT EXIST "%USERPROFILE%\Application Data\Sun\Java\Deployment\cache\tmp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Application Data\Sun\Java\Deployment\tmp\
    IF NOT EXIST "%USERPROFILE%\Application Data\Sun\Java\Deployment\cache\tmp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Cookies\
    IF NOT EXIST "%USERPROFILE%\Cookies\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Local Settings\Application Data\
    IF NOT EXIST "%USERPROFILE%\Local Settings\Application Data\IconCache.db" GOTO CD\
    DEL IconCache.db /Q
    
    :CD\
    CD %USERPROFILE%\Local Settings\History\
    IF NOT EXIST "%USERPROFILE%\Local Settings\History\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Local Settings\Temporary Internet Files\
    IF NOT EXIST "%USERPROFILE%\Local Settings\Temporary Internet Files\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\Recent\
    IF NOT EXIST "%USERPROFILE%\Recent\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %USERPROFILE%\UserData\
    IF NOT EXIST "%USERPROFILE%\UserData\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Default User\Cookies\
    IF NOT EXIST "\DOCUME~1\Default User\Cookies\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Default User\Local Settings\History\
    IF NOT EXIST "\DOCUME~1\Default User\Local Settings\History\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Default User\Local Settings\Temp\
    IF NOT EXIST "\DOCUME~1\Default User\Local Settings\Temp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Default User\Local Settings\Temporary Internet Files\
    IF NOT EXIST "\DOCUME~1\Default User\Local Settings\Temporary Internet Files\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Default User\Recent\
    IF NOT EXIST "\DOCUME~1\Default User\Recent\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Guest\Application Data\Microsoft\Office\Recent\
    IF NOT EXIST "\DOCUME~1\Guest\Application Data\Microsoft\Office\Recent\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Guest\Cookies\
    IF NOT EXIST "\DOCUME~1\Guest\Cookies\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Guest\Local Settings\Application Data\
    IF NOT EXIST "\DOCUME~1\Guest\Local Settings\Application Data\IconCache.db" GOTO CD\
    DEL IconCache.db /Q
    
    :CD\
    CD \DOCUME~1\Guest\Local Settings\History\History.IE5\
    IF NOT EXIST "\DOCUME~1\Guest\Local Settings\History\History.IE5\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Guest\Local Settings\Temp\
    IF NOT EXIST "\DOCUME~1\Guest\Local Settings\Temp\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Guest\Local Settings\Temporary Internet Files\Content.IE5\
    IF NOT EXIST "\DOCUME~1\Guest\Local Settings\Temporary Internet Files\Content.IE5\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD \DOCUME~1\Guest\Recent\
    IF NOT EXIST "\DOCUME~1\Guest\Recent\" GOTO CD\
    RD "." /S /Q
    
    :CD\
    CD %SYSTEMROOT%\system32\wdfmgr.exe
    
    CLS
     
  2. thomas234

    thomas234 Big Geek

    Likes Received:
    0
    Trophy Points:
    16
    :confused: I can't see anything wrong with it. I ran it on my computer after searching through the script and there doesn't appear to be anything missing.

    All I can think of it that these people are:

    1) Lying?
    2) Looking in the Documents section on the start menu for their files, which is actually the recent documents.
     
  3. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    thats exactly my point! The code works absolutely fine on mine but is freakin chaotic to others.
    This actually DID happen to me ONCE, during the development of the script... it happened when i replaced the "del" commands with "rd" commands. So next to the "rd" commands are "." which means remove all files and folders in that directory. I wrote a faulty "rd" code and thats when it happened, but ive long fixed that problem and i still dont understand why it happens to others.

    Maybe computers with .net? Or computers with some sort of CMD hotfix?
     
  4. thomas234

    thomas234 Big Geek

    Likes Received:
    0
    Trophy Points:
    16
    Hmmmm I'm not really sure, I don't think it's .NET as I run 3.5 on both my PC and laptop, and both are updated with the latest Windows Updates (most of the time), so I can't imagine it's some sort of hotfix.

    Maybe someone else has a suggestion?
     
  5. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    I haven't really looked through all the script but there doesn't seem to be anything wrong with it. I have a lot of work though, so you'll understand if I dont run unknown scripts for the sake of testing.

    It won't be .NET, since it's separate to the command line utilities. The only thing that could be causing a problem, though I'm not sure is environment variables. Perhaps things like systemroot are not set on some people's machines or are different. Should probably take a look into the effects of the script in those cases.
     
  6. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    personally i'm unfamiliar with Vista, however, i do remember DOS, i'll go through your bat file command by command
    do not show the command currently being executed
    correction to replace the ping command
    Code:
    CALL WAIT 10
    unnecessary
    change working directory / folder
    correction
    Code:
    if exist "%ALLUSERPROFILE%\Applic~1\Micros~1\Drwats~1" goto CD
    delete everything in & below the working directory without prompt, correct

    if you look at your script, you will see every section title is the same
    each section title should be different & i don't think they can contain special characters (\) :unsure:
     
  7. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    Thanks guys!
    and i will definitely try that out donkey ;)
     
  8. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    i was wrong about
    BTW: i made the alterations and attached it, just rename it from .TXT to .bat, i actually forgot i'd done it, till you posted
     

    Attached Files:

  9. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    I'm taking your advice on this donkey and am undergoing some overhauling. I removed the CD\'s since they are redundant.

    In addition im going to limit the RD commands. I didn't manage to use the "call wait 10" command i simply don't have that. I'll stick with the "ping" since its not a big deal.

    I'll be done with it soon enough!

    And which one of you fine lads would like to test it out? NOW NOW ONE AT A TIME!
     
  10. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    i'd try it, but, i use Kubuntu (Linux) so it won't work for me, & if i did use it i'd be ignoring myself, because, i promised myself i'd never install XP ever again except into an networking disabled VM

    Edit: i'd also recommend some kind of redundancy / error output possibly prompt for an output filename to return errors to
     
  11. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    I appreciate the courage! That's funny, i promised myself never to install Linux again! Unless, i have the time and effort to learn it again. I've tried it twice and always gave up since i was very confused (ubuntu and mandriva). I'm sure I'll try it once more in the future....

    But anyways yes a log would actually be a good idea. Now... TO WORK!
     
  12. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    well after the fiasco that was Win9x i moved to XP & i used it how M$ said it could be used & 1 clean install would only last about 2 - 3 months, i was obviously abusing it & thanks to HWF i decided to go with Kubuntu 6.06 Dapper Drake, i'm now on 8.04 Hardy Heron because i was sick of ringing MS to reactivate XP

    shall i start work on it ?
     
  13. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    Yeah. my only problem with Microsoft is its Legal annoyances and its stupid errors.

    Well, im working on shortening the code and removing the RD commands, but any LOG commands you know of would be appreciated ;)
     
  14. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    well personally i did use and like DOS & i've edited the bat file to include an error output (not finished yet) plus i am unaware of how Vista would play with the DOS commands in the bat, i've attached my work so far but please remember it's not finished & batch files are like plumbing, it only work when it's finished
     

    Attached Files:

  15. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    I'm happy to say that i've succeeded after a few days to log the events of my .BAT file (thanks in huge part by donkey :)).
    What i've done so far since the beginning of this thread:
    1 - removed the RD (remove directory) command and replaced it with less harmful DEL commands.
    2 - included a few temp folders for vista users
    3 - removed meaningless CD commands i had before
    4 - included the ">" command to output information to a .log file

    What i haven't done is added the SET commands like in donkey's attached DTMP.TXT because i didn't understand its purpose.
    Most importantly though, the RD command was the real risk taker and is now replaced. I will consider the SET commands for another time.

    Attached here is the new and improved .BAT file. Ladies and gents... i give you... CleanupManager!
    Although i explained here that a lot has been done to avoid its backfire (deleting your document folders, etc...) please BACK UP YOUR DOCUMENTS FOLDER AND ANY OTHER FILES YOU DON'T WANT DELETED IF YOUR GOING TO USE THIS.
    I'm leaving the U.S. tomorrow and won't be back until the 14th! I hope someone has the guts to run it :x:
    Till tomorrow folks
    PEACE
     

    Attached Files:

  16. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    that won't work because, it's checking if a file exists & goes to the next section, the "goto" should be after the del & you should "del *.*"[ot]i think[/ot]& i'll start on an advanced bat
     
  17. cube_

    cube_ Mega Geek

    Likes Received:
    73
    Trophy Points:
    48
    Actually, i've tested this out many times. I deliberately put the IF NOT EXIST "folder.........." GOTO #
    All its saying is that if the folder or file doesn't exist goto the next # and if it does exist, continue the next command which would be to DEL

    that would be good also BUT the only way i can use that is if i implement it like this:
    Code:
    CD\
    CD %ALLUSERSPROFILE%\Application Data\Microsoft\Dr Watson\
    DEL *.* /Q
    
    I did try this:
    Code:
    IF NOT EXIST "%ALLUSERSPROFILE%\Application Data\Microsoft\Dr Watson\" GOTO 2
    DEL *.* /q "%ALLUSERSPROFILE%\Application Data\Microsoft\Dr Watson\" > junk.log
    
    and it deleted all my desktop files where the .bat file was located including the .bat itself (good thing i had a backup)
    So im not going to add the del *.* because i don't find it safe (even if i added it like in the first code above). also, the DEL /F /S /Q works just as well and is safer.
     

Share This Page