Creating a prompt in a batch file

  • Thread starter Thread starter Thanatos
  • Start date Start date
T

Thanatos

I need to run a batch file at startup that will display a prompt for 1
minute, then close. I've made the script wait by using sleep.exe in the
win2003 resource kit, but how do i create a prompt in a batch file?
 
Bill Stewart said:
If I understand your question...

@echo off
echo Here's your prompt.
sleep whatever

HTH,

Bill

Sorry, i don't think you understood me. I'd like to have a batch file run,
that displays a prompt for two minutes where the user can type commands, but
the window must close after two minutes. With sleep.exe, the script waits,
but does not display a prompt.
 
What kind of prompt? I've done nonsense like this before:



@echo off
color E0
@echo.
@echo.
@echo.
@echo.
@echo ***************************************
@echo * *
@echo * *
@echo * Hi end-user. Process running. *
@echo * *
@echo * *
@echo ***************************************
@echo.
@echo.

Ray at work
 
Thanatos said:
I need to run a batch file at startup that will display a prompt for 1
minute, then close. I've made the script wait by using sleep.exe in the
win2003 resource kit, but how do i create a prompt in a batch file?

If I understand your question...

@echo off
echo Here's your prompt.
sleep whatever

HTH,

Bill
 
Thanatos said:
Sorry, i don't think you understood me. I'd like to have a batch file
run, that displays a prompt for two minutes where the user can type
commands, but the window must close after two minutes. With sleep.exe,
the script waits, but does not display a prompt.

You are talking about a console window that only stays open for a certain
length of time in which you can type commands, but after that it will
close? That sounds like a job for a background task with a timer. I don't
think you're going to have too easy of a time doing that without a custom
executable.

Perhaps it would be instructive if we knew your objective?
 
Thanatos wrote in
[ ]

Sorry, i don't think you understood me. I'd like to have a batch
file run, that displays a prompt for two minutes where the user
can type commands, but the window must close after two minutes.
With sleep.exe, the script waits, but does not display a prompt.

...
START "SPECIAL_$" CMD.EXE /k
ping -n 121 127.0.0.1 <nul
<path>\cmdow.exe SPECIAL_$ /CLS
...
Requires CMDOW.EXE
http://www.commandline.co.uk/
(Thanks Richie!)

I can imagine using TLIST.EXE, FIND.EXE and KILL.EXE along with batch
but won't bother as above will do it easily.
 
Mark V said:
...
START "SPECIAL_$" CMD.EXE /k
ping -n 121 127.0.0.1 <nul
<path>\cmdow.exe SPECIAL_$ /CLS

Hi Mark,

Maybe I don't understand, but what your code does is pause the "SPECIAL_$"
window for two minutes, then display a prompt. The cmdow.exe on the third
line will fail, since it gets executed immediately after the start command.

But even if I use code like this:

start /wait "SPECIAL_$" cmd.exe /k sleep 120
cmdow SPECIAL_$ /cls

What's going to happen is that the SPECIAL_$ window is going to sit there
for two minutes, but you can't type anything because sleep.exe is running.
Then it's supposed to close (I couldn't get this to work--cmdow tells me it
couldn't find the window). I don't think that's what the OP was after.

I think what he was saying is that he wants a usable cmd window for only
two minutes, and then it should close automatically.

Maybe I didn't understand his question or your solution?

Thanks,

Bill
 
Make that >, not <
Maybe I don't understand, but what your code does is pause the "SPECIAL_$"

The first line starts a new console window for the user to type in.
Then the second line is immediately executed, it waits two mins. THEN
the third line sends a Close message to the first window titled
SPECIAL_$.
window for two minutes, then display a prompt. The cmdow.exe on the third
line will fail, since it gets executed immediately after the start command.

No, see above
But even if I use code like this:

start /wait "SPECIAL_$" cmd.exe /k sleep 120
cmdow SPECIAL_$ /cls

What's going to happen is that the SPECIAL_$ window is going to sit there
for two minutes, but you can't type anything because sleep.exe is running.
Then it's supposed to close (I couldn't get this to work--cmdow tells me it
couldn't find the window).

That's because the window doesn't exist. You've started the new window with
the /wait switch, so "cmdow SPECIAL_$ /cls" is only executed when the
window titled SPECIAL_$ is closed!

Is this a different Bill Stewart? said:
I think what he was saying is that he wants a usable cmd window for only
two minutes, and then it should close automatically.

That's what Mark's solution does!
Maybe I didn't understand his question or your solution?

I don't think I fully understand what the OP wants either, but I'll take a
guess at what I think he might want:-

@echo off & setlocal ENABLEEXTENSIONS
cmdow @ /hid
start "SPECIAL_$"
ping -n 121 127.0.0.1 >nul
cmdow.exe SPECIAL_$ /CLS
exit
 
Bill Stewart wrote in
Hi Mark,

Maybe I don't understand, but what your code does is pause the
"SPECIAL_$" window for two minutes, then display a prompt. The
cmdow.exe on the third line will fail, since it gets executed
immediately after the start command.

But even if I use code like this:

start /wait "SPECIAL_$" cmd.exe /k sleep 120
cmdow SPECIAL_$ /cls

What's going to happen is that the SPECIAL_$ window is going to
sit there for two minutes, but you can't type anything because
sleep.exe is running. Then it's supposed to close (I couldn't get
this to work--cmdow tells me it couldn't find the window). I don't
think that's what the OP was after.

I think what he was saying is that he wants a usable cmd window
for only two minutes, and then it should close automatically.

Maybe I didn't understand his question or your solution?

* There was a typo in the post you replied to. A "<" where it should
have been a ">". Sorry about that.

Perhaps it is I that do not understatnd what the OP wanted...
I _thought_ I understood, but perhaps that is not the case. :-)

The code (corrected) I supplied works here to open a separate CMD
window and then close it after 2 minutes. (W2K). That is if the
window Title has not changed. A user causing the title to change
will then cause cmdow to fail (Window not found).

Perhaps the OP can better explain what is wanted.
 
Yes, my goof.
Tried multiple combinations, since I'm home sick, and all
I got was either a DOS window that can't be used, but dies
after the specified time, or a command prompt-enabled
window that won't die in the specified time.
So I'm stumped.
 
Ritchie said:
Is this a different Bill Stewart? <G>

Oh, I see where I goofed. I put a line break in there in the wrong place. I
guess that part does matter... :-)
 
Mark V said:
Bill Stewart wrote in

* There was a typo in the post you replied to. A "<" where it should
have been a ">". Sorry about that.

Perhaps it is I that do not understatnd what the OP wanted...
I _thought_ I understood, but perhaps that is not the case. :-)

The code (corrected) I supplied works here to open a separate CMD
window and then close it after 2 minutes. (W2K). That is if the
window Title has not changed. A user causing the title to change
will then cause cmdow to fail (Window not found).

Perhaps the OP can better explain what is wanted.
Ritchie, your a scholar and a gentleman =P. Your code works perfectly, does
exactly what i want. Thanks for the help
 
Back
Top