!BAT
set PTN=%1
if not "%PTN:~0,1%"=="(" echo -e \n %0 %1 - BAD ARGUMENT! && pause --wait=3 && goto :eof
# get partition type
set PT=
set PTYPE=
set P1=
parttype %PTN%
set /A P1=%@retval% > nul
set /A PT=%P1%&0xef > nul
if "%PT%"=="0xF" pause --wait=3 Extended partition entry! && exit
if "%PT%"=="" pause BAD Partition Type! && exit
if /i %PT%==0x0b set PTYPE=FAT32
if /i %PT%==0x0c set PTYPE=FAT32
if /i %PT%<=0x06 && if /i %PT%>=4 set PTYPE=FAT16
if /i %PT%==0x0e set PTYPE=FAT16
if /i %PT%==0x01 set PTYPE=FAT12
if /i %PT%==0x07 set PTYPE=NTFS_EXFAT_HFS

echo %PTYPE% %P1%
cat --hex --length=0x40 %PTN%+1

#if FAT16 then make FS invalid - 11&12hex are number of root entries which should always be 512 (0200 hex) for FAT16
#if FAT32 then make FS version invalid - 2a&2bhex are version bytes (type 0.0) - change to aaaahex so Windows won't recognise it
#if NTFS or exFAT then just changing the ID name will suffice

if "%PTYPE%"=="FAT16" cat --locate=\x00\x02 --skip=0x11 --length=2 --replace=\xaa\xaa %PTN%+1 > nul && echo Patched bytes 0x11 and 0x12! && goto :h1
if "%PTYPE%"=="FAT32" cat --locate=\x00\x00 --skip=0x2a --length=2 --replace=\xaa\xaa %PTN%+1 > nul && echo Patched bytes 0x2a and 0x2b so not recognised by Windows && goto :h1
if "%PTYPE%"=="" pause Partition type %P1% not recognised! && goto :h1

#hide NTFS and exFAT + others
cat --locate=S     --replace=s    --skip=3 --length=8 %PTN%+1 > nul
cat --locate=IBM   --replace=ibm  --skip=3 --length=8 %PTN%+1 > nul
cat --locate=FAT   --replace=fat  --skip=3 --length=8 %PTN%+1 > nul

:h1
# set partition type in MBR to hidden
debug 1
hide %PTN%

set PT=
set PTYPE=
set P1=
cat --hex --length=0x40 %PTN%+1
set PTN=
