Trying to hid the search bar for all users using REG LOAD HKU\dfltstgs "C:\Users\Default\NTUSER.DAT and its not applying the setting. All other settings I have apply and work

Troy Mattessich 0 Reputation points
2024-06-24T13:50:18.18+00:00

I'm in the process of building a Windows 11 23H2 image. I'm trying to use registry to modify the OS to my liking. I have 30 other registry settings that I have confirmed that work and I'm using batch scripting to apply the settings. During my testing, I confirmed that this first registry key,

REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchBoxTaskbarMode" /t REG_DWORD /d 0 /f

will work when run on the local administrator account and the search bar becomes hidden.

I'm trying to use REG LOAD HKU\DfltStgs "C:\Users\Default\NTUSER.DAT" followed by

REG ADD "HKU\DfltStgs\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchBoxTaskbarMode" /t REG_DWORD /d 0 /f

So that this key can be applied to any user that logs into the machine. What I found interesting is that this key is not applying the correct DWORD value to any other account that logs in besides the local admin that ran the script. However, other keys have worked with different accounts and displayed the correct value. When I look in regedit HKCU hive on any other account, I see the "SearchBoxTaskbarMode" is there, but its REG_DWORD value is a 2 even though I set it as a 0 in the script.

I'm not really sure why the value is changing. Maybe an invalid setting? Any troubleshooting tips would be appreciated.

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,885 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Ganeshkumar R 665 Reputation points
    2024-06-24T14:42:12.0366667+00:00

    The behavior you're encountering is due to the fact that certain registry settings, especially those related to user interface elements like the taskbar search box, are often managed by system processes that can override manual registry edits. This is particularly true for settings related to the Windows user experience, which might be dynamically updated based on user activity or predefined system policies.

    Here are some steps and considerations to troubleshoot and potentially resolve this issue:

    1. Ensure Consistency Across User Profiles

    The REG LOAD and REG ADD commands should work in theory, but the timing of when the registry settings are applied and when the user profile is loaded can cause issues.

    2. Check for Group Policies

    Some settings may be controlled by Group Policies which can override manual registry settings. Ensure that there are no Group Policies that reset the SearchBoxTaskbarMode setting.

    3. Use Local Group Policy Editor

    You might be able to achieve the desired setting using the Local Group Policy Editor (gpedit.msc). Here’s how you can do it:

    1. Open the Local Group Policy Editor by typing gpedit.msc in the Run dialog (Win + R).
    2. Navigate to User Configuration > Administrative Templates > Windows Components > File Explorer.
    3. Look for a policy related to the search box and configure it as needed.

    4. Script to Apply Settings on First Logon

    You can create a script that runs once at the first logon of any user to ensure the setting is applied correctly:

    1. Create a PowerShell Script:
      
         $regPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search"
      
         Set-ItemProperty -Path $regPath -Name "SearchBoxTaskbarMode" -Value 0
      
      
    2. Run the Script on First Logon:
      • Place the script in the C:\Users\Default\ profile so it runs the first time any user logs in.
      • Alternatively, use the Task Scheduler to run the script at user logon.

    5. System-Wide Configuration

    If the setting needs to be applied system-wide, you might consider running the script with elevated privileges or as a startup script:

    1. Create a Batch File:
      
         @echo off
      
         reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchBoxTaskbarMode" /t REG_DWORD /d 0 /f
      
      
    2. Schedule Task at Startup:
      • Use Task Scheduler to create a task that runs at startup with highest privileges.

    Example of a Task Scheduler XML for Startup Script:

    
    <?xml version="1.0" encoding="UTF-16"?>
    
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    
      <RegistrationInfo>
    
        <Description>Apply Taskbar Search Box Setting</Description>
    
      </RegistrationInfo>
    
      <Triggers>
    
        <LogonTrigger>
    
          <Enabled>true</Enabled>
    
        </LogonTrigger>
    
      </Triggers>
    
      <Principals>
    
        <Principal id="Author">
    
          <RunLevel>HighestAvailable</RunLevel>
    
        </Principal>
    
      </Principals>
    
      <Settings>
    
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    
        <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    
        <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    
        <AllowHardTerminate>false</AllowHardTerminate>
    
        <StartWhenAvailable>true</StartWhenAvailable>
    
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    
        <IdleSettings>
    
          <StopOnIdleEnd>false</StopOnIdleEnd>
    
          <RestartOnIdle>false</RestartOnIdle>
    
        </IdleSettings>
    
        <AllowStartOnDemand>true</AllowStartOnDemand>
    
        <Enabled>true</Enabled>
    
        <Hidden>false</Hidden>
    
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
    
        <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    
        <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    
        <WakeToRun>false</WakeToRun>
    
        <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    
        <Priority>7</Priority>
    
      </Settings>
    
      <Actions Context="Author">
    
        <Exec>
    
          <Command>powershell.exe</Command>
    
          <Arguments>-File "C:\Scripts\Set-SearchBoxTaskbarMode.ps1"</Arguments>
    
        </Exec>
    
      </Actions>
    
    </Task>
    
    
    1. Save the XML content to a file, e.g., SetSearchBoxTask.xml.
    2. Import the task using Task Scheduler:
      
         schtasks /create /tn "SetSearchBoxTask" /xml "C:\Path\To\SetSearchBoxTask.xml"
      
      

    6. Registry Redirection for 64-bit Systems

    If you are using a 64-bit version of Windows, ensure you're not running into issues with registry redirection. Explicitly specify the architecture if necessary:

    
    reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchBoxTaskbarMode" /t REG_DWORD /d 0 /f /reg:64
    
    

    By following these steps, you can ensure the SearchBoxTaskbarMode setting is applied consistently across all user profiles on your Windows 11 23H2 image.


  2. Troy Mattessich 0 Reputation points
    2024-06-24T18:22:46.63+00:00

    Hi thanks again for this help this is great to know since im a bit new to KACE2000 and scripted imaging. I found the solution.

    It turns out you need two registry settings in HKCU and HKU. The first one being SearchBarTaskMode DWORD set to 0 is still needed. The second one is SearchBarTaskModeCache needs to have a DWORD set to 1. Both of these keys need to be located in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search.

    So i just applied the second key to my HKU load and this time it worked.


  3. Troy Mattessich 0 Reputation points
    2024-06-24T18:23:20.5233333+00:00

    It turns out you need two registry settings in HKCU and HKU. The first one being SearchBarTaskMode DWORD set to 0 is still needed. The second one is SearchBarTaskModeCache needs to have a DWORD set to 1.

    Both of these keys need to be located in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search.

    So i just applied the second key to my HKU load and this time it worked.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.