×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

What is this doing?

What is this doing?

What is this doing?

(OP)
Hi everyone, Im trying to convert a batch program into visual basic and since I don't program in batch, I was wondering if anyone can please help.  I am wondering if someone can explain what this script is doing:

%SAY% Generating Multi-Boot Sector...
ECHO.>>"%TMP%\PART_1.BIN"
ECHO.>>"%TMP%\PART_1.BIN"
ECHO %ANS%>>"%TMP%\PART_1.BIN"
ECHO.>>"%TMP%\PART_1.BIN"
FOR /F "TOKENS=1,* DELIMS=/" %%A IN ('FINDSTR /I /C:"CUSTOM_BOOT_MESSAGE" "%WD%\OS.INI"') DO SET CMSG=%%B

:GENERATE_BOOT_CLASS
CALL :SET_CLASS
IF NOT DEFINED CLASS GOTO FIX_BYTES
:GENERATE_BOOT_OS
CALL :SET_OS
IF NOT DEFINED OS_REF GOTO GENERATE_BOOT_CLASS

SET COUNT=0
FOR %%A IN (%OS_LIST%) DO (
    SET /A COUNT=!COUNT! + 1
    IF "%OS_REF%" EQU "%%A" GOTO GENERATE_BOOT_MENU
)

:GENERATE_BOOT_MENU    
FOR /F "TOKENS=%COUNT%" %%A IN ("A B C D E F G H I J K L M N") DO SET LETTER=%%A
ECHO [%LETTER%] %NAME% >>"%TMP%\PART_1.BIN"
ECHO %OS_REF% >>"%TMP%\PART_2.BIN"
GSAR -o "-s:x0D:x0A" -r "%TMP%\PART_2.BIN" %NUL%
GSAR -o "-s:x20" -r "%TMP%\PART_2.BIN" %NUL%
FOR /F "TOKENS=1" %%A IN ("%OS_LIST%") DO IF "%%A" EQU "%OS_REF%" GSAR -o "-s%OS_REF%" "-r:x0%NUM%:x04%OS_REF%" "%TMP%\PART_2.BIN" %NUL%

GOTO GENERATE_BOOT_OS

:FIX_BYTES
ECHO.>> "%TMP%\PART_1.BIN"
ECHO.>> "%TMP%\PART_1.BIN"
ECHO %CMSG% >>"%TMP%\PART_1.BIN"
SET BYTES=
SET BYTEC=
ECHO ##>>"%TMP%\PART_1.BIN"
FOR /F "TOKENS=1,2 DELIMS=x " %%A IN ('GSAR.EXE -b -h "-s##:x0D:x0A" "%TMP%\PART_1.BIN"') DO IF "%%A" EQU "0" SET /A BYTEC=0x1FD - 0x%%B
FOR /L %%A IN (1,1,%BYTEC%) DO SET BYTES=:x00!BYTES!
GSAR -o "-s:x0D:x0A##:x0D:x0A" "-r:x00:x00%BYTES%" "%TMP%\PART_1.BIN" %NUL%
SET BYTES=
SET BYTEC=
ECHO ##>>"%TMP%\PART_2.BIN"
FOR /F "TOKENS=1,2 DELIMS=x " %%A IN ('GSAR.EXE -b -h "-s##:x0D:x0A" "%TMP%\PART_2.BIN"') DO IF "%%A" EQU "0" SET /A BYTEC=0xC6 - 0x%%B
FOR /L %%A IN (1,1,%BYTEC%) DO SET BYTES=:x00!BYTES!
GSAR -o "-s##:x0D:x0A" "-r%BYTES%:x55:xAA" "%TMP%\PART_2.BIN" %NUL%
COPY /Y /B "%WD%\FILES\PRE.BIN" + "%TMP%\PART_1.BIN" + "%TMP%\PART_2.BIN" "%TMP%\FINAL.BIN">NUL
:FIX_BYTES_DONE

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close