Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

User input in nt 4.0

1 view
Skip to first unread message

James Longstreet

unread,
Jun 20, 2002, 2:58:27 AM6/20/02
to
Hello,
Is there any other method besides using choice to collect user
input in an nt 4.0 bat ?

I would like the user to be prompted to enter a date and then
compare what was entered
to an already defined variable.

Many Thanks

Garry Deane

unread,
Jun 20, 2002, 12:57:18 AM6/20/02
to

You can use one of the many DOS utilities or SED as below:

for /f "tokens=*" %%a in ('SED q') do set u_input=%%a

Alternately, you can use a neat trick using the FORMAT command:

@echo off
setlocal
(echo Enter your name : )
for /f "tokens=5*" %%a in ('Format /f:160 a:^|find "..."') do (
set u_input=%%b)
echo You entered [%u_input%]

Another way is to use WSH:

@echo off
setlocal
set v_vbs=%TEMP%\~tmp.VBS
set v_cmd=%TEMP%\~tmp.cmd
> %v_vbs% ECHO Set oFS=CreateObject("Scripting.FileSystemObject")
>> %v_vbs% ECHO oFS.OpenTextFile("CON",2).Write "Enter your name : "
>> %v_vbs% ECHO S=%1(Trim(oFS.OpenTextFile("CON",1).Readline))
>> %v_vbs% ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set u_input="
>> %v_vbs% ECHO oFS.OpenTextFile("%v_cmd%",8).Write S

cscript.exe //nologo %v_vbs%
call %v_cmd%
del %v_vbs%
del %v_cmd%
echo You entered [%u_input%]

Garry

James Longstreet

unread,
Jun 20, 2002, 4:48:02 AM6/20/02
to
Gary, Thank you for the examples


"Garry Deane" <garrydeane_at_yahoo.com.au> wrote in message
news:3d115ea2...@192.168.0.2...

Solo Manalang

unread,
Jun 20, 2002, 7:57:19 AM6/20/02
to
"James Longstreet" <Longst...@hotmail.com> wrote in message news:<z%dQ8.24772$Na1.7...@news4.srv.hcvlny.cv.net>...

> Gary, Thank you for the examples
>
>
> "Garry Deane" <garrydeane_at_yahoo.com.au> wrote in message
> news:3d115ea2...@192.168.0.2...
> > On Wed, 19 Jun 2002 23:58:27 -0700, "James Longstreet"
> > <Longst...@hotmail.com> wrote:
> >
> > >Hello,
> > > Is there any other method besides using choice to collect user
> > >input in an nt 4.0 bat ?
> > >
> > > I would like the user to be prompted to enter a date and then
> > >compare what was entered
> > > to an already defined variable.
> > >
> > > Many Thanks
> >
> > You can use one of the many DOS utilities or SED as below:
> >
> > for /f "tokens=*" %%a in ('SED q') do set u_input=%%a
> >
> > Alternately, you can use a neat trick using the FORMAT command:
> >
> > @echo off
> > setlocal
> > (echo Enter your name : )
> > for /f "tokens=5*" %%a in ('Format /f:160 a:^|find "..."') do (
> > set u_input=%%b)
> > echo You entered [%u_input%]

Any chance of hiding what is being typed by ***?

Herbert Kleebauer

unread,
Jun 20, 2002, 8:43:52 AM6/20/02
to

You can use a small assembler program:

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>inp.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>inp.com
echo @]yI?@xAp~sA`LZNt@x[}?MGI@]A?nsl@]}G@tLC?sBZ`LBL`_jN0xxxxx>>inp.com

echo Enter your name:
for /f "tokens=*" %%i in ('inp.com') do set input=%%i
echo input was: %input%
del inp.com

:: The source code:
::
:: @=$100
:: move.w #buf,r1
:: move.w #1,r2
:: _10: move.b #$3f,m0
:: eor.w r3,r3
:: trap #$21
:: cmp.w r0,r2
:: bne.b _20
:: cmp.b #$0a,buf
:: beq.b _10
:: cmp.b #$0d,buf
:: bne.b _30
:: _20: rts.w
:: _30: move.b #$40,m0
:: inc.w r3
:: trap #$21
:: br.b _10
:: buf:
::

Herbert Kleebauer

unread,
Jun 20, 2002, 8:47:11 AM6/20/02
to
Solo Manalang wrote:

> > > @echo off
> > > setlocal
> > > (echo Enter your name : )
> > > for /f "tokens=5*" %%a in ('Format /f:160 a:^|find "..."') do (
> > > set u_input=%%b)
> > > echo You entered [%u_input%]
>
> Any chance of hiding what is being typed by ***?

@echo off
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
echo Enter your password:
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
echo The Password is:"%password%"


::
:: The source code:
::
:: @=$100
:: move.w #$160^$3030,-(sp)
:: move.w (sp)+,r0
:: eor.w #$3030,r0
:: move.w r0,-(sp)
:: move.w (sp)+,r3
:: move.w r0,-(sp)
:: move.w (sp)+,r1
:: inc.w r1
:: inc.w r1
:: inc.w r1
:: move.l #$23236223,-(sp)
:: move.l (sp)+,r0
:: sub.l #$24604056,r0
:: move.l r0,-(sp)
:: move.l (sp)+,r4
:: eor.l (r3.w),r4
:: eor.l r4,(r3.w)
:: eor.w #$2b2b,r0
:: bne.b $160

0 new messages