when I startup my computer a dos-sreen appears with a menu.txt which runs as
follows:
U kunt kiezen uit de volgende toepassingen:
A. Scor4
B. Word
C. CSW
D. Outlook
E. Firefox
Druk de lettertoets van uw keuze en druk op enter (Tr: Press the key of your
choice and then do Enter")
Now what I would like is, that, after pressing d, for instance, I can choose
another key without leaving outlook (in this case). But the dosscreen does
not give the possiblitiy for an input. The cursos hovers somewhere under the
prompt. When I close outlook I can press a key again.
What to do in order to be able to choose a key, and, before leaving the
application in question, to choose another one?
(I hope I made myself clear..)
Regards,
Gerard
Instead of executing say, scor4 you should START the executable
START "windowtitle" executablename executableparameters
(so much easier if you were to supply at least a representative sample of
your batch)
for instance, you may have
if /i "%response:~0,1%"=="A" scor4
change this to
if /i "%response:~0,1%"=="A" CALL "sometext" scor4
Make that
if /i "%response:~0,1%"=="A" START "sometext" scor4
Maybe it is indeed more practical when I add the script I use for loading
applications.
Let me quote what I have for "D", outlook express: (d.bat)
@echo off
if not %1#==# goto hulp
cd\
cd "c:\program files\outlook express"
msimn.exe
cd c:\bach
cls
type menu.txt
start cmd /k
:HULP
echo %0 roept de internetbrowser op en brengt u daarna weer terug naar het
menu
The question is: how to change this script in order for the menu.bat, while
outlook is still on the screen, to funtion properly, so that other
applacations of the menu-list can be chosen.
What you mentioned in your mail: if /i "%response:~0,1%"=="A" CALL
"sometext" scor4
is no stuff for a beginner, I am afraid; however, I would very much like to
hear an explanation of the script:).
Thanks in advance for your help!
Regards,
Gerard
>@echo off
>if not %1#==# goto hulp
>cd\
>cd "c:\program files\outlook express"
>msimn.exe
>cd c:\bach
>cls
>type menu.txt
>start cmd /k
This can be streamlined.
If you create c:\bach\menu.bat like this
@echo off
c:
cd "\bach"
start "" cmd /k type menu.txt
exit
then (in the case of Windows multi-threaded programs) there is no need to
change the working directory or drive, so you can use this single start
command, followed by the batch file path\name.
@echo off
if not %1#==# goto hulp
start "" "c:\program files\outlook express\msimn.exe"
c:\bach\menu.bat
You can end each menu selection batch file with c:\batch\menu.bat
Note that you do not need to use CALL c:\batch\menu.bat because it is
transferring control to c:\batch\menu.bat
Also the "" after the START keyword is required in W2K/XP/Vista etc if
there is another quoted path\filename or parameter following it.
--
Regards,
Mic
@echo off
:: label MENU - for looping
:menu
:: clear the screen
cls
:: display the menu
type menu.txt
:: force deletion of variable "response"
(set response=)
:: get a response from the user
set /p response=Druk de lettertoets van uw keuze en druk op enter
:: Just ask again if the user didn't respond
if not defined response goto menu
:: Go through the choices
if /i "%response:~0,1%"=="A" START "sometext" scor4
if /i "%response:~0,1%"=="B" START "sometext" word
:: .... and so on with other choices
:: Allow choice of "X" to exit from the menu-system
if /i "%response:~0,1%"=="X" exit
:: finally, loop back again
goto menu
should work
Note that "::" is a commonly-user replacement for REM - remarks
(set var=)
makes the SET command less vulnerable to stray spaces at the end of a line.
Some editors remove those spaces, some retain them. If there ARE spaces at
the end of lines, then
(set var=)
will set the enviroment variable 'var' to "undefined" whereas
set var=
will set the enviroment variable 'var' to have a value of the terminal
spaces on the line. This leads to hard-to-debug faults since the spaces are
not particularly visible.
if /i "%response:~0,1%"=="A" START "sometext" scor4
means
IF
/i -> case-insensitive
"..."=="..." - by quoting, the string is made insensitive to NULL contents
and spaces. It's a more robust version of your 'if not %1#==#' where the "#"
has been added in case %1 is null or a space
%response:~0,1% -> The substring of RESPONSE, starting at "character 0
(characters are numbered C-style - the first character in the string is
'character number 0)" and length 1 character. In this case, this results in
the first character of the string
START is the command to be run. START creates a new process - see the
documentation. The quoted-string as the first parameter becomes the
window-title for the new process. In theory, it's optional but best for a
beginner to always specify it - even if you make it a null-string. After the
new process is started, the batch will continue to the next line (see the
START documentation for how to change this...)
*** Note that from the prompt,
START /?
IF /?
etc. will produce documentation.
SET /?
will show information on the substringing facilities.
It would also be possible to use
...
:: Go through the choices
SET response=%response:~0,1%
if /i "%response%"=="A" START "sometext" scor4
if /i "%response%"=="B" START "sometext" word
:: .... and so on with other choices
which might be easier to maintain.
and for your purposes, perhaps
if /i "%response%"=="D" CALL d.bat
might work better for you - where you've already written D.BAT (note here
you are CALLing d.bat rather than STARTing it)
But modify D.bat as follows:
@echo off
cd\
cd "c:\program files\outlook express"
START "OUTLOOK EXPRESS" msimn.exe
cd c:\bach
** Note the START command and window-title; after MSIMN.EXE is started, its
window remains open while the batch restores the current directory to
C:\bach for the BATCH window and then the CALLed batchfile D.bat terminates;
the processing then returns to your main MENU batchfile because D.BAT was
CALLed from that MENU.BAT file.
Thank you very much!!!!!
Just one thing:
in my menu.text there is a possibility to choose a prompt with goes to a
directory called "VK".
I have made this script:
@echo off
if not %1#==# goto HULP
for %%a in (cls prompt) do %%a $p$g
cd c:\vk
uit
:HULP
echo %0 brengt u van en uit het menu naar dos
That seems a bit complicated to me.
Do you have an alternative?
I know that something like
"cd:\vk
start cmd /k"
not works, but I don't see clearly the reason for that. Could you give an
explanation?
Many thanks!
Gerard
>Just one thing:
>
>in my menu.text there is a possibility to choose a prompt with goes to a
>directory called "VK".
>
>I have made this script:
>
>@echo off
>if not %1#==# goto HULP
>for %%a in (cls prompt) do %%a $p$g
>cd c:\vk
>uit
>:HULP
>echo %0 brengt u van en uit het menu naar dos
>
>That seems a bit complicated to me.
>Do you have an alternative?
It is normal for the prompt to already be set so I omitted that.
This is not really simpler but shows a way of doing it:
@echo off
if not %1#==# goto HULP
cls
c:
cd "c:\vk"
start "" cmd /k echo VK is ready:
quit
:HULP
echo %0 brengt u van en uit het menu naar dos
--
Regards,
Mic
But now you go back to "bach", not to the "VK" directory...
Gerard
Sorry, I made a mistak, your script is OK: thank you!!
Regards,
Gerard
Having read all of the responses thus far, I'm perplexed at why you don't
assign shortcut keys to the shortcuts of the respective programs. Other than
for educational purposes, this reinvention of the wheel seems to be
defeating the purpose of the "start" menu and/or shortcut keys.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---
The answer is in the subject: "another beginner's question". Your being
perplexed perplexes me.
But feel free to explain what you mean: I am eager to learn..
Regards,
Gerard
Hi,
Thank you for your extended comment. I am afraid that it is, at this moment,
too difficult for me to understand due to lack of knowledge in this field: I
am a beginner in batch-files.
I'll save your explanation, and study, and after a certain time - not too
long I hope - I will be able to understand it and, maybe, ask for some
clarification.
Thanks again!
Regard,
Gerard
>
>
>
I typically write batches that do something which the OS does not already
provide.
e.g.
start c:\progra~1\outloo~1\msimn.exe
...is perfectly acceptable!
==
Cheers, Tim Meddick, Peckham, London. :-)
>I keep telling you, foxidrive, that including the empty quotation marks (START
>command) with a non-console app (i.e. a Windowed application) are totally
>unnecessary...
You're quite wrong.
--
Regards,
Mic
A case in point, using your short pathnames with the start command.
@echo off
md "u & me"
copy "%windir%\explorer.exe" "u & me"
start U&ME~1\explorer.exe
--
Regards,
Mic
The issue is that the inclusion of the redundant title is NEVER an error,
but the omission MAY lead to an error because the START command has
badly-defined, ambiguous syntax.
Consistent inclusion of the redundant title means that there is one fewer
side-issue to confuse the beginner.
Programmers commonly abandon the minimalist approach after they find
difficulties in maintaining their own too-clever-by-half code six months
after writing it. Sometimes it takes two or more such such experiences for
the lesson to be learned. Sometimes, the lesson is never learned and these
people tend to become managers whose talent extend to talking about the job
but not to doing it.
Your lack of quoting is not only annoying, it is obvious that you did not
read the final sentence of his post, or you refuse to acknowledge it (which
ever the case may be).
<quote>
Also the "" after the START keyword is required in W2K/XP/Vista etc if
there is another quoted path\filename or parameter following it.
</quote>
Obviously, *if* a parameter being passed requires quoting, then the
minimalist approach falls apart quickly when someone happens to copy/paste
snippets of code that exclude it.
start c:\path-to~1\some~1\prog~1.exe %1
%1 may be quoted or not quoted on a per use basis which demonstrates that
either you teach others to include the empty string consistently, or you
provide a tutorial every time someone copies minimalist code and can not
figure out why it keeps failing even after having read the start/? help over
and over.
I have to say that I didn't quite understand what it was you were saying about the
"start" syntax last time.
This is because, after some time trying to test out what I thought you were saying, I
couldn't find any ambiguities.
This was a result of, because I detest quoted long pathnames, I converted virtually
every one to the short ["dos-compatible"] form.
If the start command finds an unquoted path to a program it will execute it, even if
quotes are used as a second parameter thereafter.
But I see now how this would be confusing for beginners and all syntax should be
proofed as much as possible for all circumstances and eventualities.
...so that's me apologising then...
==
Cheers, Tim Meddick, Peckham, London. :-)
"foxidrive" <got...@woohoo.invalid> wrote in message
news:akr2p5lst2dmqmrpm...@4ax.com...