Skip to content

Commit

Permalink
Fixed Microsoft Defender false positive
Browse files Browse the repository at this point in the history
Also renamed `HideRecommendedSection` to `StartRecommendedSection`
  • Loading branch information
farag2 committed Dec 29, 2024
1 parent de30502 commit 3857183
Show file tree
Hide file tree
Showing 24 changed files with 133 additions and 133 deletions.
24 changes: 12 additions & 12 deletions Download_Latest_Sophia.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,31 @@ if (Test-Path -Path "$DownloadsFolder\$($Version)_Latest")
exit
}

New-Item -Path "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin" -ItemType Directory -Force
New-Item -Path "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries" -ItemType Directory -Force

& "$env:SystemRoot\System32\tar.exe" -C "$DownloadsFolder\SophiaScriptTemp" -xf "$DownloadsFolder\master.zip" "Sophia-Script-for-Windows-master/src/$Version"

# Download LGPO
# https://techcommunity.microsoft.com/t5/microsoft-security-baselines/lgpo-exe-local-group-policy-object-utility-v1-0/ba-p/701045
$Parameters = @{
Uri = "https://download.microsoft.com/download/8/5/C/85C25433-A1B0-4FFA-9429-7E023E7DA8D8/LGPO.zip"
OutFile = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\LGPO.zip"
OutFile = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\LGPO.zip"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters

$Parameters = @{
Path = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\LGPO.zip"
DestinationPath = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin"
Path = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\LGPO.zip"
DestinationPath = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries"
Force = $true
Verbose = $true
}
Expand-Archive @Parameters

$Parameters = @{
Path = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\LGPO_30\LGPO.exe"
Destination = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\LGPO.exe"
Path = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\LGPO_30\LGPO.exe"
Destination = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\LGPO.exe"
Force = $true
}
Move-Item @Parameters
Expand All @@ -191,19 +191,19 @@ if ($Version -match "PowerShell_7")
# https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref
$Parameters = @{
Uri = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref"
OutFile = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\microsoft.windows.sdk.net.ref.zip"
OutFile = "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\microsoft.windows.sdk.net.ref.zip"
UseBasicParsing = $true
}
Invoke-RestMethod @Parameters

# Extract Microsoft.Windows.SDK.NET.dll & WinRT.Runtime.dll from archive
Add-Type -Assembly System.IO.Compression.FileSystem
$ZIP = [IO.Compression.ZipFile]::OpenRead("$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\microsoft.windows.sdk.net.ref.zip")
$ZIP = [IO.Compression.ZipFile]::OpenRead("$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\microsoft.windows.sdk.net.ref.zip")
$Entries = $ZIP.Entries | Where-Object -FilterScript {($_.FullName -eq "lib/net8.0/Microsoft.Windows.SDK.NET.dll") -or ($_.FullName -eq "lib/net8.0/WinRT.Runtime.dll")}
$Entries | ForEach-Object -Process {[IO.Compression.ZipFileExtensions]::ExtractToFile($_, "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\$($_.Name)", $true)}
$Entries | ForEach-Object -Process {[IO.Compression.ZipFileExtensions]::ExtractToFile($_, "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\$($_.Name)", $true)}
$ZIP.Dispose()

Remove-Item -Path "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\bin\microsoft.windows.sdk.net.ref.zip" -Force
Remove-Item -Path "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries\microsoft.windows.sdk.net.ref.zip" -Force
}

$Parameters = @{
Expand All @@ -222,8 +222,8 @@ Move-Item @Parameters

$Path = @(
"$DownloadsFolder\SophiaScriptTemp",
"$DownloadsFolder\$($Version)_Latest\bin\LGPO_30",
"$DownloadsFolder\$($Version)_Latest\bin\LGPO.zip",
"$DownloadsFolder\$($Version)_Latest\Binaries\LGPO_30",
"$DownloadsFolder\$($Version)_Latest\Binaries\LGPO.zip",
"$DownloadsFolder\master.zip"
)
Remove-Item -Path $Path -Recurse -Force
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_10.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerS

Write-Verbose -Message "Sophia.Script.for.Windows.10.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_10_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_10_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe")
Destination = "Sophia_Script_for_Windows_10_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_10_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_10_LTSC_2019.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC20

Write-Verbose -Message "Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe")
Destination = "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_10_LTSC_2021.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC20

Write-Verbose -Message "Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe")
Destination = "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_10_PS_7.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerS

Write-Verbose -Message "Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe", "Scripts\WinRT.Runtime.dll", "Scripts\Microsoft.Windows.SDK.NET.dll")
Destination = "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_11.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerS

Write-Verbose -Message "Sophia.Script.for.Windows.11.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_11_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_11_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe")
Destination = "Sophia_Script_for_Windows_11_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_11_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_11_LTSC_2024.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_LTSC20

Write-Verbose -Message "Sophia.Script.for.Windows.11.LTSC.2024.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_11_LTSC_2024_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_11_LTSC_2024_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe")
Destination = "Sophia_Script_for_Windows_11_LTSC_2024_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_11_LTSC_2024_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Windows_11_PS_7.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerS

Write-Verbose -Message "Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" -Verbose

New-Item -Path "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\bin" -ItemType Directory -Force
New-Item -Path "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\Binaries" -ItemType Directory -Force

$Parameters = @{
Path = @("Scripts\LGPO.exe", "Scripts\WinRT.Runtime.dll", "Scripts\Microsoft.Windows.SDK.NET.dll")
Destination = "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\bin"
Destination = "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\Binaries"
Recurse = $true
Force = $true
}
Expand Down
6 changes: 3 additions & 3 deletions Wrapper/Config/config_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -876,13 +876,13 @@
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "HideRecommendedSection",
"Function": "StartRecommendedSection",
"Arg": {
"Zero": {
"Tag": "Disable"
"Tag": "Hide"
},
"One": {
"Tag": "Enable"
"Tag": "Show"
}
},
"Preset": "Zero",
Expand Down
6 changes: 3 additions & 3 deletions Wrapper/Config/config_Windows_11_LTSC.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,13 +896,13 @@
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "HideRecommendedSection",
"Function": "StartRecommendedSection",
"Arg": {
"Zero": {
"Tag": "Disable"
"Tag": "Hide"
},
"One": {
"Tag": "Enable"
"Tag": "Show"
}
},
"Preset": "Zero",
Expand Down
4 changes: 2 additions & 2 deletions Wrapper/Localizations/de-DE/tooltip_Windows_10.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,11 @@
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Den Navigatiosbereich des Explorers(Linker Abschnitt) nicht auf den aktuellen Ordner erweitern (aufklappen) (Standardwert)."
"ToolTip": "Den Navigatiosbereich des Explorers (Linker Abschnitt) nicht auf den aktuellen Ordner erweitern (Standardwert)."
},
"One": {
"Tag": "Enable",
"ToolTip": "Der Navigationsbereich des Explorers(Linker Abschnitt) wird auf den aktuellen Ordner erweitert (aufgeklappt)."
"ToolTip": "Der Navigationsbereich des Explorers (Linker Abschnitt) wird auf den aktuellen Ordner erweitert (aufgeklappt)."
}
}
},
Expand Down
12 changes: 6 additions & 6 deletions Wrapper/Localizations/de-DE/tooltip_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -760,25 +760,25 @@
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Den Navigatiosbereich des Explorers(Linker Abschnitt) nicht auf den aktuellen Ordner erweitern (Standardwert)."
"ToolTip": "Den Navigatiosbereich des Explorers (Linker Abschnitt) nicht auf den aktuellen Ordner erweitern (Standardwert)."
},
"One": {
"Tag": "Enable",
"ToolTip": "Der Navigationsbereich des Explorers(Linker Abschnitt) wird auf den aktuellen Ordner erweitert."
"ToolTip": "Der Navigationsbereich des Explorers (Linker Abschnitt) wird auf den aktuellen Ordner erweitert."
}
}
},
{
"Region": "UI & Personalization",
"Function": "HideRecommendedSection",
"Function": "StartRecommendedSection",
"Arg": {
"Zero": {
"Tag": "Disable",
"Tag": "Hide",
"ToolTip": "Entfernen Sie den Abschnitt Empfohlen im Startmenü. Gilt nur für die Editionen Enterprise und Education, aber nicht für IoT Enterprise."
},
"One": {
"Tag": "Enable",
"ToolTip": "Den Abschnitt Empfohlen im Startmenü nicht entfernen (Standardwert). Gilt nur für die Editionen Enterprise und Education, aber nicht für IoT Enterprise."
"Tag": "Show",
"ToolTip": "Abschnitt Empfohlen im Startmenü anzeigen (Standardwert). Gilt nur für die Editionen Enterprise und Education, aber nicht für IoT Enterprise."
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions Wrapper/Localizations/en-US/tooltip_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,15 @@
},
{
"Region": "UI & Personalization",
"Function": "HideRecommendedSection",
"Function": "StartRecommendedSection",
"Arg": {
"Zero": {
"Tag": "Disable",
"Tag": "Hide",
"ToolTip": "Remove Recommended section in Start Menu. Applicable only to Enterprise and Education editions, but not to IoT Enterprise."
},
"One": {
"Tag": "Enable",
"ToolTip": "Do not remove Recommended section in Start Menu (default value). Applicable only to Enterprise and Education editions, but not to IoT Enterprise."
"Tag": "Show",
"ToolTip": "Show Recommended section in Start Menu (default value). Applicable only to Enterprise and Education editions, but not to IoT Enterprise."
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,15 @@
},
{
"Region": "UI & Personalization",
"Function": "HideRecommendedSection",
"Function": "StartRecommendedSection",
"Arg": {
"Zero": {
"Tag": "Disable",
"Tag": "Hide",
"ToolTip": "Удалить раздел \"Рекомендуем\" в меню \"Пуск\". Применимо только к редакциям Enterprise и Education, но не к IoT Enterprise."
},
"One": {
"Tag": "Enable",
"ToolTip": "Не удалять раздел \"Рекомендуем\" в меню \"Пуск\". Применимо только к редакциям Enterprise и Education, но не к IoT Enterprise."
"Tag": "Show",
"ToolTip": "Показывать раздел \"Рекомендуем\" в меню \"Пуск\". Применимо только к редакциям Enterprise и Education, но не к IoT Enterprise."
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
}

# Checking whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
if (-not (Test-Path -Path "$PSScriptRoot\..\Binaries\LGPO.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message ($Localization.Bin -f [IO.Path]::GetFullPath("$PSScriptRoot\..\bin"))
Write-Warning -Message ($Localization.Bin -f [IO.Path]::GetFullPath("$PSScriptRoot\..\Binaries"))
Write-Information -MessageData "" -InformationAction Continue

Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" -Verbose
Expand Down Expand Up @@ -15214,11 +15214,11 @@ public static void PostMessage()
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
& "$PSScriptRoot\..\Binaries\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
& "$PSScriptRoot\..\Binaries\LGPO.exe" /t "$env:TEMP\User.txt"
}

gpupdate /force
Expand Down
8 changes: 4 additions & 4 deletions src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
}

# Checking whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
if (-not (Test-Path -Path "$PSScriptRoot\..\Binaries\LGPO.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message ($Localization.Bin -f [IO.Path]::GetFullPath("$PSScriptRoot\..\bin"))
Write-Warning -Message ($Localization.Bin -f [IO.Path]::GetFullPath("$PSScriptRoot\..\Binaries"))
Write-Information -MessageData "" -InformationAction Continue

Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" -Verbose
Expand Down Expand Up @@ -11671,11 +11671,11 @@ public static void PostMessage()
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
& "$PSScriptRoot\..\Binaries\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
& "$PSScriptRoot\..\Binaries\LGPO.exe" /t "$env:TEMP\User.txt"
}

gpupdate /force
Expand Down
8 changes: 4 additions & 4 deletions src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
}

# Checking whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
if (-not (Test-Path -Path "$PSScriptRoot\..\Binaries\LGPO.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message ($Localization.Bin -f [IO.Path]::GetFullPath("$PSScriptRoot\..\bin"))
Write-Warning -Message ($Localization.Bin -f [IO.Path]::GetFullPath("$PSScriptRoot\..\Binaries"))
Write-Information -MessageData "" -InformationAction Continue

Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" -Verbose
Expand Down Expand Up @@ -13036,11 +13036,11 @@ public static void PostMessage()
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
& "$PSScriptRoot\..\Binaries\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
& "$PSScriptRoot\..\Binaries\LGPO.exe" /t "$env:TEMP\User.txt"
}

gpupdate /force
Expand Down
Loading

0 comments on commit 3857183

Please sign in to comment.