From 5b423b8f441e2d913105bf8cf4fb94ba3e5dc7a9 Mon Sep 17 00:00:00 2001 From: ItsSiem Date: Sat, 11 Jan 2025 16:06:31 +0100 Subject: [PATCH] Added workaround for default security tweaks on 24H2 --- LabelPrinting.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/LabelPrinting.cs b/LabelPrinting.cs index cb6af6a..bd8476f 100644 --- a/LabelPrinting.cs +++ b/LabelPrinting.cs @@ -18,6 +18,10 @@ public static void printLabel(Grid grid) PSInterface.RunPowershell($"If (-NOT (Test-Path '{RPCPath}')) {{ New-Item -Path '{RPCPath}' -Force | Out-Null}}"); PSInterface.RunPowershell($"New-ItemProperty -Path '{RPCPath}' -Name 'RpcUseNamedPipeProtocol' -Value 1 -PropertyType DWORD"); + // Workaround for W11 24H2 + PSInterface.RunPowershell("Set-SmbClientConfiguration -EnableInsecureGuestLogons $true -Force"); + PSInterface.RunPowershell("Set-SmbClientConfiguration -RequireSecuritySignature $false -Force"); + // Add printer PSInterface.RunPowershell($"Add-Printer -ConnectionName \"\\\\{SettingsHandler.ReadSettings().printerHost}\\{SettingsHandler.ReadSettings().printerShareName}"); @@ -80,6 +84,10 @@ public static void printLabel(Grid grid) // Unset RPC over remote pipes PSInterface.RunPowershell($"New-ItemProperty -Path '{RPCPath}' -Name 'RpcUseNamedPipeProtocol' -Value 0 -PropertyType DWORD"); + // Reverse 24H2 workaround + PSInterface.RunPowershell("Set-SmbClientConfiguration -EnableInsecureGuestLogons $false -Force"); + PSInterface.RunPowershell("Set-SmbClientConfiguration -RequireSecuritySignature $true -Force"); + // Add printer event using (var db = new ComputerSystemContext()) {