Computing.Net > Forums > Windows XP > Batch prog

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch prog

Reply to Message Icon

Name: illy
Date: October 2, 2008 at 07:04:30 Pacific
OS: XP pro
CPU/Ram: pentium /1 gig
Product: ukn
Comment:

Hi everybody!
I have to make a batch program that will give a choice to the user:
press enter to restore or escape to backup

Those are the only two keys usable. How do I make this program. I tried with set/p and errorlevels, cant do it. Can anyone help? Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: lurkswithin
Date: October 2, 2008 at 09:01:40 Pacific
Reply:

http://www.computing.net/programmin...

It is the disadvantaged who habitually elect Democrats on the belief of personal change---
yet they remain disadvantaged.


0

Response Number 2
Name: IVO
Date: October 2, 2008 at 10:07:31 Pacific
Reply:

The following batch solves your assignment, but I doubt you can get any help from it

@echo off
set de=ASK.TXT
type NUL > %de%
echo.AAAAAAAAAAAA> %de:~0,-4%.COM

:: [Assembly_By_Debug]
echo.N %de:~0,-4%.COM>>%de%
echo.A 0100>>%de%
echo.MOV AH,08>>%de%
echo.INT 21>>%de%
echo.CMP AL,00>>%de%
echo.JNZ 010A>>%de%
echo.INT 21>>%de%
echo.MOV AH,4C>>%de%
echo.INT 21>>%de%
echo.>>%de%
echo.W>>%de%
echo.Q>>%de%
:: [End_Of_Assembly]

debug %de:~0,-4%.COM < %de% > NUL

Echo.
echo. [ENTER] for RESTORE
echo. [ESCAPE] for BACKUP
echo.
:LOOP
%de:~0,-4%.COM
if %errorlevel% equ 13 goto :RESTORE
if %errorlevel% equ 27 goto :BACKUP
goto :LOOP

:RESTORE
echo.RESTORE
goto :END
:BACKUP
echo.BACKUP
goto :END

:END
del %de%.*
set de=
:: [End_Of_Batch]


0

Response Number 3
Name: illy
Date: October 2, 2008 at 10:41:36 Pacific
Reply:

Thanks IVO it works! BUT...

What does this mean?

echo.AAAAAAAAAAAA> %de:~0,-4%.COM

My best guess would be echo AAAAAAAAAAA in the file called %de at position 0 -4%.com????


0

Response Number 4
Name: illy
Date: October 2, 2008 at 11:16:11 Pacific
Reply:

Also where can I get more information about how to use debug and all of those echo a,echo n, etc functions?
thanks


0

Response Number 5
Name: Ewen
Date: October 2, 2008 at 16:09:34 Pacific
Reply:

See response number 1 for all your programming information... forums usually work best when the proper protocols are followed

There is no such thing as Health Food... just Health Fanatics!


0

Related Posts

See More



Response Number 6
Name: IVO
Date: October 3, 2008 at 01:54:17 Pacific
Reply:

To illy

About the DEBUG command take a look at

http://technet.microsoft.com/en-us/...

The statement

echo.AAAAAAAAAAAA> %de:~0,-4%.COM

creates the file ASK.COM of lenght 14 bytes (12 As and a CR/LF), exactly the size Debug produces assembling ASK.TXT. You can't write the contents of memory without a file equal or greater to the interval to be saved.

The %de:~0,-4% is the substring from %de% with the last four position stripped away. To know about type Set /? at prompt.

The echo sequence creates the text file to be interpreted by Debug: it declares the file to be modified (N), codes the instructions (A), saves them (W) and quits (Q).

the statement

debug ASK.COM < ASK.TXT > NUL

forces Debug to read its commands from ASK.TXT, to suppress the output messages (redirected to NUL) and to operate on the ASK.COM file.

The script can be less cumbersome but I coded it just on the fly.

To Ewen,

you are right, but despite its (apparently) complexity what posted is just a plain batch and many scripts of this kind are hosted in this Forum.

My way is to help first of all.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Reformatting Computer Dell Drivers



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch prog

Batch prog needs keyboard entry XP www.computing.net/answers/windows-xp/batch-prog-needs-keyboard-entry-xp/123423.html

Batch and XP Pro www.computing.net/answers/windows-xp/batch-and-xp-pro/58767.html

Need help with batch file. www.computing.net/answers/windows-xp/need-help-with-batch-file/120558.html