Permanently Changing Column Width in Windows Explorer Search  

Page 2 of 2 FirstFirst 12

  1. Posts : 5
    Windows 10
    Thread Starter
       #11

    KeithM said:
    OK, here's version 1.0 of Set_Saved_Search_View_As_Default. When you run the code, you'll be presented with a GridVIvew control listing your saved SearchResults views, along with the FolderType used. All the common FolderTypes have a corresponding SearchResults type with the exception of Downloads, which uses its base type for search results as well. You have to set a default for each type to override its default. Possible search result types are:

    Downloads
    Contacts.SearchResults
    Documents.SearchResults
    OtherUsers.SearchResults
    Pictures.SearchResults
    Communications.SearchResults
    UsersLibraries.SearchResults
    Music.SearchResults
    Generic.SearchResults
    PublishedItems.SearchResults
    UserFiles.SearchResults
    Videos.SearchResults

    Though it's unlikely most users will ever see all of those. In the GridView, select the folder(s) you want copy as a template for its FolderType. You can only have one template for each type, if you select a type that already has an entry under AllFolders, or if you select more than one of the same type, the last one written will be the one to survie.

    Attachment 321460

    Select the Folders/Types and click OK. PowerShell will display confimation for each view copied:
    Code:
     . . .
    >> '@ -f $Splat )
    >> }
    >>
    Default view set for: Pictures.SearchResults
               Based on: "Search Results in Spring 2015" ( Bag #949 )
               Key Name: HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell\{4DCAFE13-E6A7-4C28-BE02-CA8C2126280D}



    Copy & paste directly into PowerShell or save as a .ps1 file.

    Code:
    ### String constans
    $ShellKey    = 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell'
    $BagMRU      = "$ShellKey\BagMRU"
    $Bags        = "$ShellKey\Bags"
    $ConfirmCopy = @'
    
    Default view set for: {0}
                Based on: "{1}" ( Bag #{2} )
                Key Name: {3}
    
    '@
    
    ### Dictonary FOlderTYpeID -> FolderType.CanonicalName
    $FTKey     = Get-Item 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes'
    $FT_Lookup = $FTKey.GetSubkeyNames() | ForEach{ $hash = @{'{25CC242B-9A7C-4F51-80E0-7A2928FEBE42}'='Network'} } {
         $hash.Add( $_, $FTKey.OpenSubkey($_).GetValue('CanonicalName') )
    } { $hash }
    
    
    $Shell  = New-Object -ComObject shell.application
    (Get-Item $BagMRU).Property -match '\d+' | ForEach{
    Try{
        [PSCustomObject]@{
            'Bag'  = Get-ItemPropertyValue "$BagMRU\$_" NodeSlot
            'Name' = ( $Shell.NameSpace(( Get-ItemPropertyValue $BagMRU $_ ))).Title
        } 
    } Catch {}
    } | Where Name -match 'Search Results' |
        Where { (Test-Path "$Bags\$($_.Bag)\Shell") -and (Get-Item "$Bags\$($_.Bag)\Shell").SubKeyCount } | ForEach{
        $Splat = @{
            'NotePropertyName'  = 'Type'
            'NotePropertyValue' = $FT_Lookup[( Get-Item "$Bags\$($_.Bag)\Shell" ).GetSubkeyNames()]
            'PassThru'          = $True
        }
        $_ | Add-Member @Splat
    } | Group Name | ForEach {
        [PSCustomObject]@{
            'Name'   = $_.Name
            'Bag'    = $_.Group.Bag
            'Type'   = $_.Group.Type | Select -Unique
        }
    
    ### *** Launch GridView for folder selection ***
    
    } | Out-GridView -PassThru | ForEach{
    
    ### Confirm copy
        $Splat = @(
            $_.Type
            $_.Name
            $_.Bag
            ( Copy-Item -Path "$Bags\$($_.Bag)\Shell\*" -Destination "$Bags\AllFolders\Shell" -Recurse -Force -PassThru ).Name.Replace( 'HKEY_CURRENT_USER' , 'HKCU' )
        )
        Write-Output ( $ConfirmCopy -f $Splat )
    
    ### Apply to existing?
        If ( ( Read-Host 'Apply this template to any currenly saved views of the same type? (Y/N)' ) -match '^y') {
            Get-ChildItem $Bags -Recurse -Depth 2 |
              Where PSChildName -eq $Splat[3].Split('\')[-1] |
              Where Name -notMatch AllFolders |
            Remove-Item -Recurse -Force
        }
    }
    Apologize for the late response, but your first method worked! I didn't know Windows 10 had an internal memory for these kind of stuff. Thank you for your help!

    Now Im wondering whether the registry limit has anything to do with my Bluetooth and 2.4 gHz wireless mouse/keyboard to also stop working. Nevertheless, I can't thank you both enough.

    Cheers,

    Peter
      My Computer


  2. Posts : 988
    Microsoft Windows 10 Home
       #12

    You're welcome. If you're always initiating your searches from the same high-level location(s), then the built-in functionality may serve all your needs. But if you launch a search from a previously unsearched subfolder, you'll probalby be greeted with Content view. My code allows you to replace that default with your preferreed view settings. Even if you don't use it, I think others will. Associating bags with their corresponding folder in the Shell Namespace has always been a stumbling block --- Bags are indexed by BagMRU and its subkeys: loads of byte arrays intended solely for Explorer and its APIs. Then I discovered some undocumented functionality that allows me to "translate" those values via the scriptable Shell COM object without the API hassle. But I hadn't thought to pair that trick with this issue and a GridView control. It's a lot better than using ProcMon or other tricks I've used in the past. So thanks for inspiring a fresh look.
      My Computer


  3. Posts : 10
    Windows 10
       #13

    I don't quite understand what I'm supposed to do to set view for search results. I read through these posts and tried pasting the code from post #10 into PowerShell to no avail, but it returned nothing. Can someone try again to explain what to do?
      My Computer


  4. Posts : 16,005
    Windows 10 Home x64 Version 22H2 Build 19045.3448
       #14

    zylstra said:
    I don't quite understand what I'm supposed to do to set view for search results. I read through these posts and tried pasting the code from post #10 into PowerShell to no avail, but it returned nothing. Can someone try again to explain what to do?
    Use WinSetView, a utility created by Les Ferch, a TenForums member.
    WinSetView (Tool to Globally Set Explorer Folder Views)


    All the best,
    Denis
      My Computer


  5. Posts : 533
    Windows 10/11
       #15

    As @Try3 stated, use WinSetView. It will let you change the default column widths. I'm here if you have any questions.
      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 21:27.
Find Us




Windows 10 Forums