Skip to content

Instantly share code, notes, and snippets.

@gabrielstelmach
gabrielstelmach / DecToHex.bat
Created June 22, 2023 19:28
Batch script to convert decimal in hexa values
@echo off & setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set LOOKUP=0123456789abcdef &set HEXSTR=&set PREFIX=
if "%1"=="" echo 0&goto :EOF
set /a A=%* || exit /b 1
if !A! LSS 0 set /a A=0xfffffff + !A! + 1 & set PREFIX=f
:loop
set /a B=!A! %% 16 & set /a A=!A! / 16
set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR%
if %A% GTR 0 goto :loop
echo %PREFIX%%HEXSTR%
@gabrielstelmach
gabrielstelmach / BruteForceDiscover.bat
Created June 22, 2023 19:31
Attempts to switch Logitech device to channel 2 using all possible values
@echo off
setlocal EnableDelayedExpansion
rem Run trough values 0 to 31 in hex for position C
for /L %%a in (0, 1, 31) do (
for /F %%b in ('DecToHex.bat %%a') do (
@set "hex_c=%%b"
rem Pad left 0
if "%%a" lss 16 (
@set "hex_c=0!hex_c!"