Need Help With Batch File

Discussion in 'other software & services' started by Brandonn2010, Dec 30, 2014.

  1. Brandonn2010

    Brandonn2010 Registered Member

    Joined:
    Jan 10, 2011
    Posts:
    1,849
    So something I normally do is delete leftover files from uninstalled programs in ProgramData and AppData folders. However, I always have to unhide all folders, change the attributes on those folders to keep them unhidden, then hide all hidden files again.

    I tried to make a batch file to do this, and tested it on my computer. I thought it had worked, yet when I tried to run it on another computer, it didn't work correctly, even though I had added wildcard characters.

    Here are the contents of the batch file. Please let me know what, if anything, needs to be fixed:

    ATTRIB -H "C:\Users\%username%\AppData\*" /S /D
    ATTRIB -H "C:\ProgramData\*" /S /D

    pause

    Thanks
     
  2. phalanaxus

    phalanaxus Registered Member

    Joined:
    Jan 19, 2011
    Posts:
    499
    Try this instead

    c:
    attrib -h %userprofile%\appdata\* /s /d
    attrib -h %allusersprofile%\* /s /d
     
  3. Minimalist

    Minimalist Registered Member

    Joined:
    Jan 6, 2014
    Posts:
    5,066
    When you run this batch file, does it give you any errors?
     
  4. Brandonn2010

    Brandonn2010 Registered Member

    Joined:
    Jan 10, 2011
    Posts:
    1,849
    Tried it. Most files say "Access Denied" even though I run it as an administrator. However, ProgramData seems to be unhidden, but AppData doesn't seem to run at all.
     
  5. markymoo

    markymoo Registered Member

    Joined:
    Sep 25, 2007
    Posts:
    1,212
    Location:
    England
    Appdata is a system folder. You have to use the system attribute at same time as the hidden attribute because a system file or folder is extra hidden. A system file or system folder cannot be unhidden without -s.

    This will work

    Code:
    ATTRIB -H -S "C:\Users\%username%\AppData\*" /S /D
    ATTRIB -H -S "C:\ProgramData\*" /S /D
    

    and with the read only flag.

    Code:
    ATTRIB -H -S -R "C:\Users\%username%\AppData\*" /S /D
    ATTRIB -H -S -R "C:\ProgramData\*" /S /D
    
     
    Last edited: Jan 2, 2015
  6. phalanaxus

    phalanaxus Registered Member

    Joined:
    Jan 19, 2011
    Posts:
    499
    Ok here's another shot, it should work independent of the windows installation drive. Add -s switch after attrib command to reveal system files too.

    Code:
    %homedrive%
    ATTRIB -H -R "%homepath%\AppData\*" /S /D
    ATTRIB -H -R "%allusersprofile%\*" /S /D
    
     
  7. Brandonn2010

    Brandonn2010 Registered Member

    Joined:
    Jan 10, 2011
    Posts:
    1,849
    Still won't work, still getting "access denied" errors.
     
Loading...