ChangeByteInBinaryFile

'Change Ptn4 Type byte in a MBR BIN file to Type 0 to remove partition'e.g. cscript tweakbyte.vbs "K:\TEST ss.MBR"
Const ForReading = 1Const ForWriting = 2Dim fso, fileSet fso = CreateObject("Scripting.FileSystemObject")
' Specify the binary file path from first argumentfile1 = WScript.Arguments.Item(0)
' Specify the address of the byte to be modified 498=0x1F2  = Partition 4 Type Number if MBRaddress = 498newbyte = 0
address = address + 1' Open the binary fileSet file = fso.GetFile(file1)If Err.number <> 0 Then MsgBox(Err.message)On Error GoTo 0WScript.Echo "Reading file..."With file.OpenAsTextStream() binaryData = .Read(file.Size) .CloseEnd With
' Modify the byte at the specified addressbinaryData = Left(binaryData, address - 1) & Chr(newbyte) & Right(binaryData, Len(binaryData) - address)
' Open the binary file for writingSet file = fso.createTextFile(file1)    If Err.number <> 0 Then MsgBox(Err.message)    On Error GoTo 0Set file = NothingWith fso.createTextFile(file1) .Write(binaryData) .CloseEnd With ' Inform the user that the binary file has been modifiedWScript.Echo "The binary file has been modified."

The above vbscript can be used to change the value of a single byte in a binary file.

It writes a byte of 0 to offset 498  in this example.

You can pass the address and byte value on the command line by replacing the lines for address and newbyte

address = WScript.Arguments.Item(1)
newbyte = WScript.Arguments.Item(2)
' Specify the address of the byte to be modified 498=0x1F2  = Partition 4 Type Number if MBR
'address = 0
'newbyte = 33

e.g. cscript tweakbyte.vbs "K:\TEST SS.MBR" 32 255


P.S. The Windows utility bytepatch.exe can also be used for several bytes, e.g.

bytepatch.exe FILE.BIN -a 494 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

https://bytepointer.com/tools/index.htm#bytepatch