diff --git a/Sophia/LTSC/Sophia.ps1 b/Sophia/LTSC/Sophia.ps1 index 2311d4a9..1642ac41 100644 --- a/Sophia/LTSC/Sophia.ps1 +++ b/Sophia/LTSC/Sophia.ps1 @@ -2,17 +2,16 @@ .SYNOPSIS Default preset file for "Windows 10 Sophia Script" (LTSC version) - Version: v5.1.1 - Date: 17.03.2021 + Version: v5.1.2 + Date: 27.03.2021 Copyright (c) 2015–2021 farag & oZ-Zo - https://github.com/farag2 - https://github.com/oz-zo - Thanks to all https://forum.ru-board.com members involved .DESCRIPTION Read carefully and configure the preset file before running + Comment out function with the "#" char if you don't want it to be run + Uncomment function by removing the "#" char if you want it to be run Every tweak in the preset file has its' corresponding function to restore the default settings Running the script is best done on a fresh install because running it on wrong tweaked system may result in errors occurring @@ -23,12 +22,6 @@ .EXAMPLE .\Sophia.ps1 -Functions CreateRestorePoint, "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal" - .NOTES - https://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 - https://habr.com/post/521202/ - https://forums.mydigitallife.net/threads/powershell-windows-10-sophia-script.81675/ - https://www.reddit.com/r/PowerShell/comments/go2n5v/powershell_script_setup_windows_10/ - .NOTES Supported Windows 10 version Version: 1809 @@ -40,6 +33,20 @@ Set execution policy to be able to run scripts only in the current PowerShell session: Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force + .NOTES + https://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 + https://habr.com/post/521202/ + https://forums.mydigitallife.net/threads/powershell-windows-10-sophia-script.81675/ + https://www.reddit.com/r/PowerShell/comments/go2n5v/powershell_script_setup_windows_10/ + + .LINK + https://t.me/sophianews + https://t.me/sophia_chat + + .LINK + https://github.com/farag2 + https://github.com/Inestic + .LINK https://github.com/farag2/Windows-10-Sophia-Script #> @@ -57,7 +64,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.1.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" +$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.1.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force @@ -593,7 +600,7 @@ PCTurnOffDevice -Disable # Переопределить метод ввода по умолчанию: английский SetInputMethod -English -# Override for default input method: use langiage list (default value) +# Override for default input method: use language list (default value) # Переопределить метод ввода по умолчанию: использовать список языков (значение по умолчанию) # SetInputMethod -Default @@ -964,7 +971,7 @@ SaveZoneInformation -Disable # Enable Windows Sandbox # Включить Windows Sandbox -WindowsSandbox -Enable +# WindowsSandbox -Enable # Disable Windows Sandbox (default value) # Выключить Windows Sandbox (значение по умолчанию) diff --git a/Sophia/LTSC/Sophia.psd1 b/Sophia/LTSC/Sophia.psd1 index b0ad98d3..ccfdd70c 100644 Binary files a/Sophia/LTSC/Sophia.psd1 and b/Sophia/LTSC/Sophia.psd1 differ diff --git a/Sophia/LTSC/Sophia.psm1 b/Sophia/LTSC/Sophia.psm1 index 67ecade7..9ad6bbf5 100644 --- a/Sophia/LTSC/Sophia.psm1 +++ b/Sophia/LTSC/Sophia.psm1 @@ -2,24 +2,15 @@ .SYNOPSIS "Windows 10 Sophia Script" (LTSC version) is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks - Version: v5.1.1 - Date: 17.03.2021 + Version: v5.1.2 + Date: 27.03.2021 Copyright (c) 2015–2021 farag & oZ-Zo - https://github.com/farag2 - https://github.com/oz-zo - Thanks to all https://forum.ru-board.com members involved .DESCRIPTION Running the script is best done on a fresh install because running it on wrong tweaked system may result in errors occurring - .NOTES - https://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 - https://habr.com/post/521202/ - https://forums.mydigitallife.net/threads/powershell-windows-10-sophia-script.81675/ - https://www.reddit.com/r/PowerShell/comments/go2n5v/powershell_script_setup_windows_10/ - .NOTES Supported Windows 10 version Version: 1809 @@ -31,6 +22,20 @@ Set execution policy to be able to run scripts only in the current PowerShell session: Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force + .NOTES + https://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 + https://habr.com/post/521202/ + https://forums.mydigitallife.net/threads/powershell-windows-10-sophia-script.81675/ + https://www.reddit.com/r/PowerShell/comments/go2n5v/powershell_script_setup_windows_10/ + + .LINK Telegram channel & group + https://t.me/sophianews + https://t.me/sophia_chat + + .LINK + https://github.com/farag2 + https://github.com/Inestic + .LINK https://github.com/farag2/Windows-10-Sophia-Script #> @@ -155,7 +160,7 @@ function CreateRestorePoint # Revert the System Restore checkpoint creation frequency to 1440 minutes New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 1440 -Force - # Turn off System Protection for the system drive if it was turned off without deleting existing restore points + # Turn off System Protection for the system drive if it was turned off before without deleting the existing restore points if ($ComputerRestorePoint) { Disable-ComputerRestore -Drive $env:SystemDrive @@ -1660,6 +1665,8 @@ function 3DObjects # In order for the changes to take effect the File Explorer process has to be restarted Stop-Process -Name explorer -Force + Start-Sleep -Seconds 3 + # Restoring closed folders foreach ($OpenedFolder in $OpenedFolders) { @@ -2849,66 +2856,101 @@ function TempFolder { "SystemDrive" { - # Restart the Printer Spooler service (Spooler) - Restart-Service -Name Spooler -Force - - if (-not (Test-Path -Path $env:SystemDrive\Temp)) + if ($env:TEMP -ne "$env:SystemDrive\Temp") { - New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force - } + # Restart the Printer Spooler service (Spooler) + Restart-Service -Name Spooler -Force - Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore - Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + # Stop OneDrive processes + Stop-Process -Name OneDrive -Force -ErrorAction Ignore + Stop-Process -Name FileCoAuth -Force -ErrorAction Ignore - if (Test-Path -Path $env:LOCALAPPDATA\Temp -ErrorAction Ignore) - { - if ((Get-ChildItem -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Measure-Object).Count -ne 0) + if (-not (Test-Path -Path $env:SystemDrive\Temp)) + { + New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force + } + + # Cleaning up folders + Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore + Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + + if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) { - Invoke-Item -Path $env:LOCALAPPDATA\Temp + New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force + } + + # If there are some files or folders left in $env:LOCALAPPDATA\Temp + if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0) + { + # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa + # The system does not move the file until the operating system is restarted + # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files + $Signature = @{ + Namespace = "WinAPI" + Name = "DeleteFiles" + Language = "CSharp" + MemberDefinition = @" +public enum MoveFileFlags +{ + MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004 +} + +[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] +static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags); - do +public static bool MarkFileDelete (string sourcefile) +{ + return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); +} +"@ + } + + if (-not ("WinAPI.DeleteFiles" -as [type])) { - $Title = "" - $Message = $Localization.ClearFolder -f "$env:LOCALAPPDATA\Temp" - $Delete = $Localization.Delete - $Skip = $Localization.Skip - $Options = "&$Delete", "&$Skip" - $DefaultChoice = 0 - - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) - { - "0" - { - # Create a symbolic link to the %SystemDrive%\Temp folder - try - { - Get-Item -Path $env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore - New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force -ErrorAction SilentlyContinue - } - catch [System.Exception] - { - Write-Verbose -Message $Localization.FilesBlocked -Verbose - Write-Verbose -Message ((Get-ChildItem -Path $env:LOCALAPPDATA\Temp -Force).FullName | Out-String) -Verbose - } - } - "1" - { - Write-Verbose -Message $Localization.SymbolicSkipped -Verbose - } - } + Add-Type @Signature + } + + try + { + Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + } + catch + { + # If files are in use remove them at the next boot + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } - until (((Get-ChildItem -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Measure-Object).Count -eq 0) -or ($Result -eq 1)) + + $SymbolicLinkTask = @" +Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force + +Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force +New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force + +Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false +"@ + + # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder + $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask" + $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME + $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 + $Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest + $Parameters = @{ + "TaskName" = "SymbolicLink" + "Principal" = $Principal + "Action" = $Action + "Settings" = $Settings + "Trigger" = $Trigger + } + Register-ScheduledTask @Parameters -Force + } + else + { + # Create a symbolic link to the %SystemDrive%\Temp folder + New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force } - } - else - { - # Create a symbolic link to the %SystemDrive%\Temp folder - New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force - } - if (Get-Item -Path $env:LOCALAPPDATA\Temp -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"}) - { + #region main + # Change the %TEMP% environment variable path to "%LOCALAPPDATA%\Temp" [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User") [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine") [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process") @@ -2921,49 +2963,116 @@ function TempFolder New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force + # endregion main } } "Default" { - # Remove a symbolic link to the %SystemDrive%\Temp folder - if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"}) + if ($env:TEMP -ne "$env:LOCALAPPDATA\Temp") { - (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete() - } + # Restart the Printer Spooler service (Spooler) + Restart-Service -Name Spooler -Force - if (-not (Test-Path -Path $env:SystemRoot\Temp)) - { - New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force - } - if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) - { - New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force - } + # Stop OneDrive processes + Stop-Process -Name OneDrive -Force -ErrorAction Ignore + Stop-Process -Name FileCoAuth -Force -ErrorAction Ignore - # Restart the Printer Spooler service (Spooler) - Restart-Service -Name Spooler -Force + # Remove a symbolic link to the %SystemDrive%\Temp folder + if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"}) + { + (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete() + } - if ((Get-ChildItem -Path $env:SystemDrive\Temp -Force -ErrorAction Ignore | Measure-Object).Count -eq 0) - { - Remove-Item -Path $env:SystemDrive\Temp -Recurse -Force - } - else - { - Write-Verbose -Message ($Localization.TempNotEmpty -f $env:TEMP) -Verbose - } + if (-not (Test-Path -Path $env:SystemRoot\Temp)) + { + New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force + } + if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) + { + New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force + } - [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User") - [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine") - [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process") - New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:LOCALAPPDATA\Temp -Force + # Removing folders + Remove-Item -Path $env:TEMP -Recurse -Force -ErrorAction Ignore - [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User") - [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine") - [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process") - New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:LOCALAPPDATA\Temp -Force + if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0) + { + # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa + # The system does not move the file until the operating system is restarted + # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files + $Signature = @{ + Namespace = "WinAPI" + Name = "DeleteFiles" + Language = "CSharp" + MemberDefinition = @" +public enum MoveFileFlags +{ + MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004 +} + +[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] +static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags); + +public static bool MarkFileDelete (string sourcefile) +{ + return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); +} +"@ + } - New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemRoot\TEMP -Force - New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value $env:SystemRoot\TEMP -Force + if (-not ("WinAPI.DeleteFiles" -as [type])) + { + Add-Type @Signature + } + + try + { + Remove-Item -Path $env:TEMP -Recurse -Force -ErrorAction Stop + } + catch + { + # If files are in use remove them at the next boot + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + } + + $TempFolder = [System.Environment]::ExpandEnvironmentVariables($env:TEMP) + $TempFolderCleanupTask = @" +Remove-Item -Path "$TempFolder" -Recurse -Force + +Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false +"@ + + # Create a temporary scheduled task to clean up the temporary folder + $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask" + $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME + $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 + $Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest + $Parameters = @{ + "TaskName" = "TemporaryTask" + "Principal" = $Principal + "Action" = $Action + "Settings" = $Settings + "Trigger" = $Trigger + } + Register-ScheduledTask @Parameters -Force + } + + #region main + # Change the %TEMP% environment variable path to "%LOCALAPPDATA%\Temp" + [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User") + [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine") + [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process") + New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force + + [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User") + [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine") + [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process") + New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force + + New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force + New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force + # endregion main + } } } } @@ -5104,6 +5213,8 @@ function WinPrtScrFolder # In order for the changes to take effect the File Explorer process has to be restarted Stop-Process -Name explorer -Force + Start-Sleep -Seconds 3 + # Restoring closed folders foreach ($OpenedFolder in $OpenedFolders) { @@ -5628,7 +5739,7 @@ function Set-Association Param ( [Parameter( - Mandatory = $false, + Mandatory = $true, Position = 0 )] [String] @@ -5647,6 +5758,7 @@ function Set-Association ) $ProgramPath = [System.Environment]::ExpandEnvironmentVariables($ProgramPath) + $Icon = [System.Environment]::ExpandEnvironmentVariables($Icon) if (Test-Path -Path $ProgramPath) { @@ -5819,6 +5931,7 @@ namespace RegistryUtils $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($SubKey,'ReadWriteSubTree','TakeOwnership') $Acl = [System.Security.AccessControl.RegistrySecurity]::new() + # Get current user SID $UserSID = (Get-CimInstance -ClassName Win32_UserAccount | Where-Object -FilterScript {$_.Name -eq $env:USERNAME}).SID $Acl.SetSecurityDescriptorSddlForm("O:$UserSID`G:$UserSID`D:AI(D;;DC;;;$UserSID)") $OpenSubKey.SetAccessControl($Acl) @@ -5846,6 +5959,20 @@ namespace RegistryUtils $OrigProgID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Classes\$Extension" -Name "(default)" -ErrorAction Ignore)."(default)" + if ($OrigProgID) + { + # Save possible ProgIds history with extension + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgID`_$Extension" -PropertyType String -Value 0 -Force + } + + $Name = (Get-Item -Path $ProgramPath).Name + $Extension + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name $Name -PropertyType String -Value 0 -Force + + if ("$ProgId`_$Extension" -ne $Name) + { + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId`_$Extension" -PropertyType String -Value 0 -Force + } + # If ProgId doesn't exist set the specified ProgId for the extansions if (-not $OrigProgID) { @@ -5856,7 +5983,7 @@ namespace RegistryUtils New-ItemProperty -Path "HKCU:\SOFTWARE\Classes\$Extension" -Name "(default)" -PropertyType String -Value $ProgId -Force } - # Set the specified ProgId в варианты возможных для назначения + # Set the specified ProgId in the possible options for the assignment if (-not (Test-Path -Path "HKCU:\SOFTWARE\Classes\$Extension\OpenWithProgids")) { New-Item -Path "HKCU:\SOFTWARE\Classes\$Extension\OpenWithProgids" -Force @@ -5872,14 +5999,12 @@ namespace RegistryUtils } New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids" -Name $OrigProgID -PropertyType None -Value ([byte[]]@()) -Force } - else + + if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) { - if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) - { - New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids" -Force - } - New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids" -Name $ProgID -PropertyType None -Value ([byte[]]@()) -Force + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids" -Force } + New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids" -Name $ProgID -PropertyType None -Value ([byte[]]@()) -Force # Removing the UserChoice key Remove-UserChoiceKey -SubKey "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice" @@ -5933,13 +6058,6 @@ namespace RegistryUtils New-ItemProperty -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds -Name "_$Extension" -PropertyType DWord -Value 1 -Force } - # Save possible ProgIds with extension - if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts")) - { - New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Force - } - New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" -Name "$ProgId`_$Extension" -PropertyType String -Value 0 -Force - # Setting 'NoOpenWith' for all registered the extension ProgIDs [psobject]$OpenSubkey = Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore | Select-Object -ExpandProperty Property @@ -6124,7 +6242,9 @@ namespace FileAssoc { [OutputType([array])] + # Secret static string stored in %SystemRoot%\SysWOW64\shell32.dll $userExperience = "User Choice set via Windows User Experience {D18B6DD5-6124-4341-9318-804003BAFA0B}" + # Get user SID $userSid = (Get-CimInstance -ClassName Win32_UserAccount | Where-Object -FilterScript {$_.Name -eq $env:USERNAME}).SID $KeyLastWriteTime = Get-KeyLastWriteTime -SubKey $SubKey $baseInfo = ("{0}{1}{2}{3}{4}" -f $Extension, $userSid, $ProgId, $KeyLastWriteTime, $userExperience).ToLowerInvariant() @@ -6846,7 +6966,7 @@ function SoftwareDistributionTask $SoftwareDistributionTask = @" (Get-Service -Name wuauserv).WaitForStatus('Stopped', '01:00:00') -Get-ChildItem -Path $env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force +Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null @@ -6941,7 +7061,7 @@ function TempTask "Register" { $TempTask = @" -"Get-ChildItem -Path $env:TEMP -Force -Recurse | Remove-Item -Recurse -Force" +Get-ChildItem -Path `$env:TEMP -Force -Recurse | Remove-Item -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null @@ -7384,6 +7504,8 @@ function DismissSmartScreenFilter .EXAMPLE AuditProcess -Enable + + .NOTES Machine-wide #> function AuditProcess @@ -7436,6 +7558,8 @@ function AuditProcess .NOTES In order this feature to work events auditing ("AuditProcess -Enable" function) will be enabled + + .NOTES Machine-wide #> function AuditCommandLineProcess @@ -7491,6 +7615,8 @@ function AuditCommandLineProcess .NOTES In order this feature to work events auditing ("AuditProcess -Enable" function) and command line in process creation events will be enabled + + .NOTES Machine-wide #> function EventViewerCustomView @@ -7570,6 +7696,8 @@ function EventViewerCustomView .EXAMPLE PowerShellModulesLogging -Enable + + .NOTES Machine-wide #> function PowerShellModulesLogging @@ -7625,6 +7753,8 @@ function PowerShellModulesLogging .EXAMPLE PowerShellScriptsLogging -Enable + + .NOTES Machine-wide #> function PowerShellScriptsLogging @@ -7678,6 +7808,8 @@ function PowerShellScriptsLogging .EXAMPLE AppsSmartScreen -Enable + + .NOTES Machine-wide #> function AppsSmartScreen @@ -7785,6 +7917,8 @@ function SaveZoneInformation .NOTES Blocks WSH from executing .js and .vbs files + + .NOTES Current user #> function WindowsScriptHost @@ -7838,6 +7972,8 @@ function WindowsScriptHost .EXAMPLE WindowsSandbox -Enable + + .NOTES Current user #> function WindowsSandbox @@ -7933,6 +8069,8 @@ function WindowsSandbox .EXAMPLE MSIExtractContext -Add + + .NOTES Current user #> function MSIExtractContext @@ -7989,6 +8127,8 @@ function MSIExtractContext .EXAMPLE CABInstallContext -Add + + .NOTES Current user #> function CABInstallContext @@ -8045,6 +8185,8 @@ function CABInstallContext .EXAMPLE RunAsDifferentUserContext -Add + + .NOTES Current user #> function RunAsDifferentUserContext @@ -8094,6 +8236,8 @@ function RunAsDifferentUserContext .EXAMPLE CastToDeviceContext -Show + + .NOTES Current user #> function CastToDeviceContext @@ -8147,6 +8291,8 @@ function CastToDeviceContext .EXAMPLE ShareContext -Show + + .NOTES Current user #> function ShareContext @@ -8200,6 +8346,8 @@ function ShareContext .EXAMPLE EditWithPaint3DContext -Show + + .NOTES Current user #> function EditWithPaint3DContext @@ -8257,6 +8405,8 @@ function EditWithPaint3DContext .EXAMPLE PrintCMDContext -Show + + .NOTES Current user #> function PrintCMDContext @@ -8308,6 +8458,8 @@ function PrintCMDContext .EXAMPLE IncludeInLibraryContext -Show + + .NOTES Current user #> function IncludeInLibraryContext @@ -8357,6 +8509,8 @@ function IncludeInLibraryContext .EXAMPLE SendToContext -Show + + .NOTES Current user #> function SendToContext @@ -8406,6 +8560,8 @@ function SendToContext .EXAMPLE BitLockerContext -Show + + .NOTES Current user #> function BitLockerContext @@ -8471,6 +8627,8 @@ function BitLockerContext .EXAMPLE BitmapImageNewContext -Add + + .NOTES Current user #> function BitmapImageNewContext @@ -8547,6 +8705,8 @@ function BitmapImageNewContext .EXAMPLE RichTextDocumentNewContext -Add + + .NOTES Current user #> function RichTextDocumentNewContext @@ -8623,6 +8783,8 @@ function RichTextDocumentNewContext .EXAMPLE CompressedFolderNewContext -Add + + .NOTES Current user #> function CompressedFolderNewContext @@ -8677,6 +8839,8 @@ function CompressedFolderNewContext .EXAMPLE MultipleInvokeContext -Disable + + .NOTES Current user #> function MultipleInvokeContext @@ -8726,6 +8890,8 @@ function MultipleInvokeContext .EXAMPLE UseStoreOpenWith -Show + + .NOTES Current user #> function UseStoreOpenWith @@ -8779,6 +8945,8 @@ function UseStoreOpenWith .EXAMPLE PreviousVersionsPage -Show + + .NOTES Current user #> function PreviousVersionsPage diff --git a/Sophia/LTSC/cn-CN/Sophia.psd1 b/Sophia/LTSC/cn-CN/Sophia.psd1 index a150c6e5..cb84840f 100644 --- a/Sophia/LTSC/cn-CN/Sophia.psd1 +++ b/Sophia/LTSC/cn-CN/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = 该脚本支持Windows 10版本1809 UnsupportedRelease = 找到新版本 ControlledFolderAccessDisabled = “受控文件夹访问”禁用 ScheduledTasks = 计划任务 -ClearFolder = 删除“{0}“文件夹中的所有文件? -FilesBlocked = 以下文件被第三方应用程序阻止。手动删除它们并继续 -TempNotEmpty = “{0}“文件夹不为空。 手动清除 WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化 @@ -46,7 +43,6 @@ ErrorsMessage = 错误/警告 Add = 添加 AllFilesFilter = 所有文件 (*.*)|*.* Change = 更改 -Delete = 删除 DialogBoxOpening = 显示对话窗口…… Disable = 禁用 Dismiss = 解雇 diff --git a/Sophia/LTSC/de-DE/Sophia.psd1 b/Sophia/LTSC/de-DE/Sophia.psd1 index 949dcb04..e04953c5 100644 --- a/Sophia/LTSC/de-DE/Sophia.psd1 +++ b/Sophia/LTSC/de-DE/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Das Skript unterstützt Windows 10 1 UnsupportedRelease = Neue Version gefunden ControlledFolderAccessDisabled = Kontrollierter Ordnerzugriff deaktiviert ScheduledTasks = Geplante Aufgaben -ClearFolder = Löscht alle Dateien im Ordner "{0}"? -FilesBlocked = Die folgenden Dateien werden von Apps von Drittanbietern blockiert. 'nEntfernen Sie sie manuell und fahren Sie fort -TempNotEmpty = Der Ordner "{0}" ist nicht leer. Löschen Sie ihn manuell WindowsFeaturesTitle = Windows Eigenschaften OptionalFeaturesTitle = Optionale Eigenschaften EnableHardwareVT = Virtualisierung in UEFI aktivieren @@ -46,7 +43,6 @@ ErrorsMessage = Fehler/Warnungen Add = Hinzufügen AllFilesFilter = Alle Dateien (*.*)|*.* Change = Ändern -Delete = Löschen DialogBoxOpening = Anzeigen des Dialogfensters... Disable = Deaktivieren Dismiss = Stornieren diff --git a/Sophia/LTSC/en-US/Sophia.psd1 b/Sophia/LTSC/en-US/Sophia.psd1 index 7806e8a2..1ce23d76 100644 --- a/Sophia/LTSC/en-US/Sophia.psd1 +++ b/Sophia/LTSC/en-US/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = The script supports Windows 10 1809 UnsupportedRelease = New version found ControlledFolderAccessDisabled = Controlled folder access disabled ScheduledTasks = Scheduled tasks -ClearFolder = Delete all files in the "{0}" folder? -FilesBlocked = The following files are being blocked by third-party party apps. Remove them manually and continue -TempNotEmpty = The "{0}" folder is not empty. Clear it manually WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Errors/Warnings Add = Add AllFilesFilter = All Files (*.*)|*.* Change = Change -Delete = Delete DialogBoxOpening = Displaying the dialog box... Disable = Disable Dismiss = Dismiss diff --git a/Sophia/LTSC/es-ES/Sophia.psd1 b/Sophia/LTSC/es-ES/Sophia.psd1 index 5b5aab85..025feff0 100644 --- a/Sophia/LTSC/es-ES/Sophia.psd1 +++ b/Sophia/LTSC/es-ES/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Este script solo soporta Windows 10 UnsupportedRelease = Nueva versión encontrada ControlledFolderAccessDisabled = Acceso a carpetas controlado desactivado ScheduledTasks = Tareas programadas -ClearFolder = Elimine todos los archivos en la carpeta "{0}"? -FilesBlocked = Los siguientes archivos están siendo bloqueados por una aplicación de terceros. Elimínelos manualmente y continúe -TempNotEmpty = La carpeta "{0}" no está vacía. Límpiela manualmente WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Activar virtualización en UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Errores/Advertencias Add = Añadir AllFilesFilter = Tutti i file (*.*)|*.* Change = Cambiar -Delete = Borrar DialogBoxOpening = Mostrando caja de diálogo... Disable = Desactivar Dismiss = Despedir diff --git a/Sophia/LTSC/fr-FR/Sophia.psd1 b/Sophia/LTSC/fr-FR/Sophia.psd1 index 863d1154..174c1750 100644 --- a/Sophia/LTSC/fr-FR/Sophia.psd1 +++ b/Sophia/LTSC/fr-FR/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Le script supporte le version Window UnsupportedRelease = Nouvelle version trouvée ControlledFolderAccessDisabled = Contrôle d'accès aux dossiers désactivé ScheduledTasks = Tâches planifiées -ClearFolder = Supprimer tous les fichiers dans le dossier "{0}"? -FilesBlocked = Les fichiers suivants sont bloqués par une application tierce \nRetirer les manuellement et continuer -TempNotEmpty = Le dossier "{0}" n'est pas vide. L'effacer manuellement WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Erreurs/Avertissements Add = Ajouter AllFilesFilter = Tous les Fichiers (*.*)|*.* Change = Changer -Delete = Effacer DialogBoxOpening = Afficher la boîte de dialogue... Disable = Désactiver Dismiss = Annuler diff --git a/Sophia/LTSC/it-IT/Sophia.psd1 b/Sophia/LTSC/it-IT/Sophia.psd1 index 578e9bd6..0a150506 100644 --- a/Sophia/LTSC/it-IT/Sophia.psd1 +++ b/Sophia/LTSC/it-IT/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Lo script supporta Windows 10 versio UnsupportedRelease = Nuova versione trovata ControlledFolderAccessDisabled = l'accesso alle cartelle controllata disattivata ScheduledTasks = Attività pianificate -ClearFolder = Eliminare tutti i file nella cartella "{0}"? -FilesBlocked = I seguenti file vengono bloccati da app di terze parti. Rimuovili manualmente e continua -TempNotEmpty = La cartella "{0}" non è vuota. Cancellare manualmente WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Errori/avvisi Add = Inserisci AllFilesFilter = Tutti i file (*.*)|*.* Change = Modificare -Delete = Elimina DialogBoxOpening = Visualizzazione della finestra di dialogo... Disable = Disattivare Dismiss = Ignorare diff --git a/Sophia/LTSC/pt-BR/Sophia.psd1 b/Sophia/LTSC/pt-BR/Sophia.psd1 index 4324a74b..92fa7241 100644 --- a/Sophia/LTSC/pt-BR/Sophia.psd1 +++ b/Sophia/LTSC/pt-BR/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = O script suporta versões Windows 10 UnsupportedRelease = Nova versão encontrada ControlledFolderAccessDisabled = Acesso controlado a pasta desativada ScheduledTasks = Tarefas agendadas -ClearFolder = Exclua todos os arquivos na pasta "{0}"? -FilesBlocked = Os seguintes arquivos estão sendo bloqueados pelos apps de terceiros. Removê-los manualmente e continuar -TempNotEmpty = A pasta "{0}" não está vazia. Limpá-la manualmente WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Erros/Avisos Add = Adicionar AllFilesFilter = Todos os arquivos (*.*)|*.* Change = Mudar -Delete = Excluir DialogBoxOpening = Exibindo a caixa de diálogo... Disable = Desativar Dismiss = Ignorar diff --git a/Sophia/LTSC/ru-RU/Sophia.psd1 b/Sophia/LTSC/ru-RU/Sophia.psd1 index 26b07b09..a118487d 100644 --- a/Sophia/LTSC/ru-RU/Sophia.psd1 +++ b/Sophia/LTSC/ru-RU/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Скрипт поддерживае UnsupportedRelease = Обнаружена новая версия ControlledFolderAccessDisabled = Контролируемый доступ к папкам выключен ScheduledTasks = Запланированные задания -ClearFolder = Удалить все файлы в папке "{0}"? -FilesBlocked = Следующие файлы блокируются сторонними приложениями. Удалите их вручную и продолжите -TempNotEmpty = Папка "{0}" не пуста. Очистите ее вручную WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Ошибки/предупрежде Add = Добавить AllFilesFilter = Все файлы (*.*)|*.* Change = Изменить -Delete = Удалить DialogBoxOpening = Диалоговое окно открывается... Disable = Отключить Dismiss = Отмена diff --git a/Sophia/LTSC/tr-TR/Sophia.psd1 b/Sophia/LTSC/tr-TR/Sophia.psd1 index c5e25be7..3bc14fc7 100644 --- a/Sophia/LTSC/tr-TR/Sophia.psd1 +++ b/Sophia/LTSC/tr-TR/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Bu betik sadece Windows 10 1809 Ente UnsupportedRelease = Yeni sürüm bulundu ControlledFolderAccessDisabled = Kontrollü klasör erişimi devre dışı bırakıldı ScheduledTasks = Zamanlanan görevler -ClearFolder = "{0}" klasöründeki tüm dosyaları silin? -FilesBlocked = Aşağıdaki dosyalar 3. parti uygulamalar tarafından engelleniyor. \nKendiniz silin ve devam edin -TempNotEmpty = "{0}" klasörü boş değil. Kendiniz temizleyin WindowsFeaturesTitle = Windows özellikleri OptionalFeaturesTitle = İsteğe bağlı özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin @@ -46,7 +43,6 @@ ErrorsMessage = Hatalar/Uyarılar Add = Ekle AllFilesFilter = Tüm Dosyalar (*.*)|*.* Change = Değiştir -Delete = Sil DialogBoxOpening = İletişim kutusu görüntüleniyor... Disable = Devre dışı bırak Dismiss = İptal diff --git a/Sophia/LTSC/uk-UA/Sophia.psd1 b/Sophia/LTSC/uk-UA/Sophia.psd1 index 61b38a3c..a55bfc26 100644 --- a/Sophia/LTSC/uk-UA/Sophia.psd1 +++ b/Sophia/LTSC/uk-UA/Sophia.psd1 @@ -4,9 +4,6 @@ UnsupportedOSBuild = Скрипт підтримує ті UnsupportedRelease = Виявлено нову версію ControlledFolderAccessDisabled = Контрольований доступ до папок вимкнений ScheduledTasks = Заплановані задачі -ClearFolder = Видаліть всі файли у папці "{0}"? -FilesBlocked = Наступні файли блокуються сторонніми програмами\nВидаліть їх вручну та продовжуйте -TempNotEmpty = Папка "{0}" не порожня. Очистіть її вручну WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI @@ -46,7 +43,6 @@ ErrorsMessage = Помилки/попереджен Add = Додати AllFilesFilter = Усі файли (*.*)|*.* Change = Змінити -Delete = Видалити DialogBoxOpening = Діалогове вікно відкривається... Disable = Вимкнути Dismiss = Відміна