batch program works.. once?

- / -
January 14, 2009 at 23:48:30
Specs: windows xp/2k/nt, -
I started a new thread because this issue is not related to one I had before.

I have a program that asks for user to log in, after that it gives user X amount of seconds to give a work ID. If the user hasn't responded the program will go back to login-screen.

I run the program in full-screen (just set all bat-files to be run in full-screen).
Everything else is ok, but when I have either made the first work log or waited for the program to log me out automatically, the program doesn't work as supposed. I DO get into the login-screen but when I try to log in, it fails to do so? Any ideas?

I will paste here what I have come up with, program consist of three files;
- login.bat asks for user id.
- logwork.bat asks for work id.
- wait.bat sets the reply time for user.


@echo off
setlocal EnableDelayedExpansion

set ID=
set /P ID=Log in (any string of characters): 
start wait.bat
start %0 logwork.bat



@echo off

cls & echo %ID%
set /P WORK=Insert work (any string of characters): 
taskkill /F /FI "WINDOWTITLE eq waitforit" > NUL
echo marked %ID% %WORK% %COMPUTERNAME% %DATE% %TIME% >> %ID%.log

echo Marked:
echo "%WORK%"
echo Logging out . . .
FOR /l %%a in (5,-1,1) do (echo %%as&ping -n 2 -w 1 localhost>NUL)
start login.bat
ping -n 1 -w 1 localhost>NUL


@echo off

ping -n 10 localhost>NUL
taskkill /F /FI "WINDOWTITLE eq logwork"
start login.bat
ping -n 2 localhost>NUL

And please do not laugh at my code, this is only the second "real" program I am writing with batch :) I'm sure there are tons of bugs and glitches and I'm sure it's not even supposed to work...

See More: batch program works.. once?

Report •

January 14, 2009 at 23:53:20
Both logwork.bat and wait.bat have "start login.bat" that restart the script. I'm guessing that modifying them would solve my problem, but I don't know what I should do...

Thank you!

Report •

January 15, 2009 at 07:40:58
Your script are a bit too sophisticated for me to understand them in the 30 seconds of spare time I have, but I noticed this:


What's that supposed to do?

I'm not saying that's causing any problems, but it may be. It depends if you have a variable called TITLE. (I know what the TITLE command does, but %TITLE% puzzles me.)

Report •

January 15, 2009 at 08:09:50
Oh snap! You've got it! It now works like a charm (had to add it a small killswitch for extra window though)! I have no idea why I wrote that, it was just a part of someone else's code and I think I just blindly took it with the "TITLE=" without examining it further.

Thank you klint!

Well, here we have a (couple of) program(s) with "set /P" and it(they) actually waits for the user to reply in X amount of time!

Report •

Related Solutions

January 15, 2009 at 09:40:13
That's clever - a bit of a sledgehammer approach, but there's not many ways to get SET /P to time out!

I would prefer to download and use choice.exe but in some situations that's not possible.

Report •

January 15, 2009 at 12:18:36
Aye, as it is in my case where choises are unlimited ;)

Report •

Ask Question