rem This work by http://blog.dest-unreach.be/ is licensed under a Creative rem Commons Attribution-Noncommercial-Share Alike 2.0 Belgium License. @echo off C:/Windows/system32/WindowsPowerShell/v1.0/powershell.exe -ExecutionPolicy remotesigned -NoProfile -NonInteractive -Command "$p = \"%OPENVPN_IP6_PREFIX%\"; if ( $p.substring($p.length-5).compareTo(\"::/64\") ) { echo \"IPv6 prefix does not look like a /64 subnet\"; exit 1 }; $a=gwmi win32_NetworkAdapter -filter \"netconnectionid = '%DEV%'\"; $a.MACAddress -match '([0-9a-fA-F]*):([0-9a-fA-F]*):([0-9a-fA-F]*):([0-9a-fA-F]*):([0-9a-fA-F]*):([0-9a-fA-F]*)' | out-null; $slaac=[string]::join(':', $p.split(':')[0..3])+':'+ ('{0:X0}' -f [convert]::ToInt32($matches[1],16) -bxor 2 ) +$matches[2]+':'+$matches[3]+'ff:fe'+$matches[4]+':'+$matches[5]+$matches[6]; C:\Windows\System32\netsh interface ipv6 add address \"%DEV%\" $slaac; exit 0" < NUL if ERRORLEVEL 1 goto end C:/Windows/system32/WindowsPowerShell/v1.0/powershell.exe -ExecutionPolicy remotesigned -NoProfile -NonInteractive -Command "$r = \"%OPENVPN_IP6_ROUTES%\"; $g=\"%OPENVPN_IP6_GW%\"; $r.split(' ') | %% { c:\Windows\System32\route add $_ $g }" < NUL :end