cancel
Showing results for 
Search instead for 
Did you mean: 

Batch files

N/A

Batch files

I have a suite of utilities as part of a system restoration program. It is designed to boot a diskless system of a floppy and restore to HD to its original format.

At the moment, i might as well carry around the 72 CD's needed to restore each type of system, as the existing method is slow, complex and doesn't bode well to forgetfulness.

My only problem at the moment, is trying to obtain some user input and storing it to a variable.

This input is needed to be able to load a specific library file, and the utilities I would normaly run, are not avilable unless this library is loaded.

Is there any way to get user input from the keyboard and store it to a variable?

It must be upto the return key, and not single keys.
11 REPLIES
Community Veteran
Posts: 6,983
Thanks: 8
Registered: 10-04-2007

Batch files

Philip
Just had a browse through my old and dusty DOS5 manual.
It looks like the command "Set" could be the sort of thing you are looking for?

Quote from book Set displays, sets, or removes environmental variables.

Is this any use to you.
N/A

Batch files

That will set the environment variable yes.

What I actualy need is a section of batch code that can extract the input from the keyboard, and place it as a value in a specific variable.

AKA, doing a set, without doing the set Tongue

I have found a small amount of code, though it is way to advanced for me. So i am going to play on a system that it can't hurt Tongue
Community Veteran
Posts: 6,983
Thanks: 8
Registered: 10-04-2007

Batch files

Ok I'll have a further dig through my DOS manual and if I find anything else then I will let you know.
I do recall years ago creating a batch file to select different option from the keyboard but I'm fairly sure that it was just a key press of a single key from an option list which is not what you need in this instance,
N/A

Batch files

There is the choice command for single key press's.

I am working on another disk now, as will see how that comes out - Only it means a walk to the other side of the building to keep testing it Tongue
N/A

Batch files

There are plenty of old dos prog about you need. Norton Utils used to have a good one the is one call ask.exe and if you search lots of others to do these little jobs.

There are loads here
http://www.cse.ucsc.edu/~pang/fltk/fltk/win32/1.0.9/test/

including the ask.exe

I dont understand why you want all these cd etc. System restoe can be simple using ghost and if you sysprep win2k or xp one image will do for most pc.s
N/A

Batch files

All the systems are ME and 98.

We allready use ghost. For each hardware setup, it varies from 2 to 6 disks.

I am slowly condencing them down to a network share and with the aid of a bootdisk, a single question upon bootup, the system will automaticly restore itself without telling it which hardware setup is in use.

The process of asking the equestion is to gether the systems serial number. This is used as part of the network logon details and is why I can't ask ti after this step.

Without asking, I don't have access to the network share with all the other utilities on it.

I encountered a small hitch and have given up for the day. I will have a look at ask.exe tomorrow.

The problem I had is that the utility to ask the question writes to disk before reading it back into the variable.

This is not possible with CD media (which the code will eventualy go onto).
N/A

Batch files

the simple answer is to use a simple file like
cls
echo what is your system
echo choose 1 2 or 3.

then have a 1.bat a 2,bat etc not rocket science but simple and it works
N/A

Batch files

Point taken.

The problem with that is it isn't very dynamic. A batch file is required for each system.

I have had one thought of using generic login details, then dynamicaly generating the batch file with my other utilities.

Allthough it isn't what we wanted, passign username and password details for the "NET USE" command should do.
N/A

Batch files

How about passing the input you want as a parameter to another batch file.

Autoexec could prompt for the command (batch file name + serial number). The second batch file does whatever validation you need then set %var%=%1....
N/A

Batch files

Yes, however, that doesn't help the target audiance of the system.

I have almost implimented my second approach now. The rest of the software now needs rewritting to accomodate these changes, but it seems the simplest approach for now (there is also a lot more contorl with this one).
Mark_Dowd
Grafter
Posts: 102
Registered: 08-08-2007

Batch files

If batch file management is an issue, it is also possible to have a single batch file, containing all of the code, to call itself recursively. The top-level call may contain a parameter, but subsequent calls, down the stack, would take additional parameters to direct program flow.

For example, I wrote the following batch file to help me analyse duplicate files on network servers. It produces comma-delimited files, which can be imported into Excel etc.

Quote
@echo off
REM ****************************************************************************************************
REM * files.bat
REM * Usage
REM * -----
REM * files dirname [outfilename] - Initiates the process
REM * files DIR dirname - Processes a directory
REM ****************************************************************************************************

if '%1'=='DIR' goto DIR

if not "%2"=="" set outfile=%2
if "%outfile%"=="" set outfile=c:\output.csv

REM ****************************************************************************************************
REM * Process all directories
REM ****************************************************************************************************
if not "%1"=="" set root=%1

for /f "tokens=1,2*" %%a in ('dir %root% /s ^|find "Directory of"') do call %0 DIR "%%c"
goto scram

REM ****************************************************************************************************
REM * DIR - Process directory passed in %2
REM ****************************************************************************************************
CheesyIR
echo Processing %2

for /f "tokens=1,2,3*" %%a in ('dir %2 /ta /a-d /-c ^|find "/"') do echo %2,%%a,%%b,%%c,%%d>>%outfile%
for /f "tokens=1,2,3*" %%a in ('dir %2 /ta /-c ^|find "<DIR>"') do echo %2,%%a,%%b,0,%%d>>%outfile%
goto scram

REM ****************************************************************************************************
REM * Exit point
REM ****************************************************************************************************
:scram