Disassembler0 / Win10-Initial-Setup-Script

PowerShell script for automation of routine tasks done after fresh installations of Windows 10 / Server 2016 / Server 2019
MIT License
4.7k stars 1.08k forks source link

3dObject Folder on 1803 ---> If($Win10Ver -ge 1709){ #212

Closed xinxilas closed 5 years ago

xinxilas commented 5 years ago

I have Windows 1803, and the folder wasnt removed

Is there anything wrong with this line? If($Win10Ver -ge 1709){ From here:

    If($Win10Ver -ge 1709){
        If($ThreeDobjectsIconInThisPC -eq 0) {
            If($ShowSkipped -eq 1){ DisplayOut 'Skipping 3D Object folder in This PC...' -C 15 }
        } ElseIf($ThreeDobjectsIconInThisPC -eq 1) {
            DisplayOut 'Showing 3D Object folder in This PC...' -C 11
            $Path = '\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag'
            $Path1 = '\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}'
            New-Item -Path "HKLM:\SOFTWARE\$Path" | Out-Null
            New-Item -Path "HKLM:\SOFTWARE\$Path1" | Out-Null
            Set-ItemProperty -Path "HKLM:\SOFTWARE\$Path" -Name 'ThisPCPolicy' -Type String -Value 'Show'
            If($OSBit -eq 64){
                New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\$Path" | Out-Null
                Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\$Path" -Name 'ThisPCPolicy' -Type String -Value 'Show'
                New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\$Path1" | Out-Null
            }
        } ElseIf($ThreeDobjectsIconInThisPC -eq 2) {
            DisplayOut 'Hiding 3D Object folder in This PC...' -C 12
            $Path = '\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag'
            Set-ItemProperty -Path "HKLM:\SOFTWARE\$Path" -Name 'ThisPCPolicy' -Type String -Value 'Hide'
            If($OSBit -eq 64){ Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\$Path" -Name 'ThisPCPolicy' -Type String -Value 'Hide' }
        } ElseIf($ThreeDobjectsIconInThisPC -eq 3) {
            DisplayOut 'Removing 3D Object folder in This PC...' -C 13
            RemoveSetPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}'
            RemoveSetPath 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}'
        }
    }
Disassembler0 commented 5 years ago

This isn't from my script. No idea where you got it.

The problem may be that under option 2, the registry key isn't created before its property is set. There should be a New-Item call in similar fashion as it is under option 1. You can crosscheck it with what I have in the script:

https://github.com/Disassembler0/Win10-Initial-Setup-Script/blob/b3b12239ecae4143f908d547ff3210027a32ad94/Win10.psm1#L2194-L2226