Attempting to set hidden attribute to start menu folders via cmd


  1. Posts : 3
    Windows 10
       #1

    Attempting to set hidden attribute to start menu folders via cmd


    Ok, so I've been working on my unattended install and I am hitting a wall. I currently am using classic shell start menu to replace the original and I want to set the default start menu folders to hidden for two reasons. First reason being that I already have links for each of these located in classic start menu and don't need a second set sitting in my programs folder. Second reason, if I delete them(which doesn't work either), windows updates like to replace a few of these every now and then.

    Here is what I'm attempting to do via .bat file:

    Code:
    takeown /f "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance" /r /d y > NUL 2>&1
    icacls "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance" /grant administrators:F /t > NUL 2>&1
    takeown /f "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Accessories" /r /d y > NUL 2>&1
    icacls "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Accessories" /grant administrators:F /t > NUL 2>&1
    takeown /f "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Administrative Tools" /r /d y > NUL 2>&1
    icacls "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Administrative Tools" /grant administrators:F /t > NUL 2>&1
    takeown /f "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Ease of Access" /r /d y > NUL 2>&1
    icacls "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Ease of Access" /grant administrators:F /t > NUL 2>&1
    takeown /f "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows System" /r /d y > NUL 2>&1
    icacls "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows System" /grant administrators:F /t > NUL 2>&1
    attrib +H "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance" > NUL 2>&1
    attrib +H "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Accessories" > NUL 2>&1
    attrib +H "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Administrative Tools" > NUL 2>&1
    attrib +H "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Ease of Access" > NUL 2>&1
    attrib +H "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows System" > NUL 2>&1
    takeown /f "%appdata%\Microsoft\Windows\Start Menu\Programs\Maintenance" /r /d y > NUL 2>&1
    icacls "%appdata%\Microsoft\Windows\Start Menu\Programs\Maintenance" /grant administrators:F /t > NUL 2>&1
    takeown /f "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Accessories" /r /d y > NUL 2>&1
    icacls "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Accessories" /grant administrators:F /t > NUL 2>&1
    takeown /f "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Administrative Tools" /r /d y > NUL 2>&1
    icacls "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Administrative Tools" /grant administrators:F /t > NUL 2>&1
    takeown /f "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Ease of Access" /r /d y > NUL 2>&1
    icacls "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Ease of Access" /grant administrators:F /t > NUL 2>&1
    takeown /f "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell" /r /d y > NUL 2>&1
    icacls "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell" /grant administrators:F /t > NUL 2>&1
    takeown /f "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows System" /r /d y > NUL 2>&1
    icacls "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows System" /grant administrators:F /t > NUL 2>&1
    attrib +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Maintenance" > NUL 2>&1
    attrib +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Accessories" > NUL 2>&1
    attrib +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Administrative Tools" > NUL 2>&1
    attrib +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows Ease of Access" > NUL 2>&1
    attrib +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell" > NUL 2>&1
    attrib +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Windows System" > NUL 2>&1
    I verified that takeown and icacls are returning successfully, but the ONLY folder this works on is the Maintenance folder from both the programdata and appdata locations. The rest of the folders not only persist, but if I try to delete them via explorer I receive a pop up saying I need admin access, click ok and it deletes. So obviously something is preventing or retaking ownership of the folders??

    The account is an admin with UAC disabled and the bat file uses an auto-elevation to run as administrator, so I know that rights are fine. Any help would be appreciated. Open to use cmd, powershell, or even a 3rd party program as long as I can run it in a portable solution.
      My Computer


  2. Posts : 3
    Windows 10
    Thread Starter
       #2

    Ok, so I found out how to set hidden attributes via powershell using this command:

    Code:
    (Get-Item “Folder Path”).Attributes = ‘Hidden’
    When I use this code it works successfully on the Maintenance folder, but any of the others error out saying that the directory doesn't exist. What am I missing here?
      My Computer


  3. Posts : 3
    Windows 10
    Thread Starter
       #3

    So for whatever reason, when viewing in explorer those folders are named as I have them in my bat file. If I open cmd and go into the directory and get the listing, the folders have a different name. I have changed my bat file to match the folder names found through cmd and everything works as it should. Now I'm left with 2 unimportant questions:

    1. Why did the takeown and icacls return as successful for folders that aren't there?
    2. Does it have to do with those folders being linked together, like a library maybe?
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:36.
Find Us




Windows 10 Forums