@echo off setlocal rem Adds the gateway and keeps the ones you already have (with a backup). rem gw.nynusoft.com powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop';$path='Software\Battle.net\Configuration';$name='Battle.net Gateways';$a='gw.nynusoft.com';$z='0';$t='gw.nynusoft.com';$b=Join-Path $env:USERPROFILE ('battle.net-gateways-' + (Get-Date -f yyyyMMdd-HHmmss) + '.reg');reg export 'HKCU\Software\Battle.net\Configuration' $b /y 2>&1 | Out-Null;try {$k=[Microsoft.Win32.Registry]::CurrentUser.CreateSubKey($path);$cur=$k.GetValue($name);if ($cur -is [string]) { Write-Host 'Battle.net Gateways is not a list: use gateway.reg or regedit.'; exit 1 };if (-not $cur) { $cur=@() };$s=@($cur);if ($s.Count -gt 2 -and $s[0] -eq '1001') { $s=$s[2..($s.Count-1)] };$g=@();for ($i=0; $i -lt $s.Count-2; $i+=3) { $g+=,@($s[$i],$s[$i+1],$s[$i+2]) };$g=@($g | Where-Object { $_[0] -ne $a });$g+=,@($a,$z,$t);$f=@('1001',('{0:d2}' -f $g.Count));foreach ($x in $g) { $f+=$x };$k.SetValue($name,[string[]]$f,[Microsoft.Win32.RegistryValueKind]::MultiString);if (@($k.GetValue($name)).Count -ne $f.Count) { Write-Host 'The registry did not end up as expected; check it with regedit.'; exit 1 };$k.Close();Write-Host ('Gateway added: ' + $a + ' | Backup saved to: ' + $b);exit 0} catch {Write-Host ('Error: ' + $_.Exception.Message); exit 1}" if errorlevel 1 (echo Something failed: read the message above.) echo. pause