Skip to content

Commit

Permalink
Added workaround for default security tweaks on 24H2
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSiem committed Jan 11, 2025
1 parent bf81827 commit 5b423b8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions LabelPrinting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");

Expand Down Expand Up @@ -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())
{
Expand Down

0 comments on commit 5b423b8

Please sign in to comment.