|
Answer» I haven't written a batch file since ADAM was a boy, but a situation has come upwhere I think one is needed. we use a SIMPLE HTML file as a signature file for our email system (Lotus Notes) the bosses want all users to have a sig file, and for it to be consistent. Not many users can code in HTML, and so it is shaping up that I will need to do a file for each of them. Rather than do this I thought a quick batch file that asks the users name, section, phone number, etc, then outputs the HTML file. But I can't find how I ask the user for input. I am SURE it is possible, and I am sure it is easy, but I just can't find a reference. everything I find only allows simple input, like CHOICE.
Can anybody either tell me or point me to a resource that does?
ThanksBatch is poor when it comes to user input unless predetermined (list) of choices for Choice command ( if this do that ).
a VB Script would give you what you want.Maybe someone here more savy in vbscripting can give you a example of how to ask for input and output that to a file to compose the html file out of the vbscriptCouldn't SET/P be used as in:
SET/P username=Please enter your name: cls SET/P section=Please enter your section: cls SET/P phone#=Please enter your phone#: cls echo %username% %section% %phone#% > %temp%userinfo.txt
Sorry, I'm not up to HTML coding, leave that to you..
Hope this helps & welcome to the forums.THANK you for the replies. Unfortunately not enough time for me to learn VBScript. I will try the set and see whether this works, I think it will.
Thanks again Code: [Select]@echo off
:start cls set username= set section= set phone#=
cls SET/P username=Please enter your name: cls SET/P section=Please enter your section: cls SET/P phone#=Please enter your phone#: cls set /p correct=Was all this information correct(Y/N): if /i %correct%==n goto start if /i %correct%==y goto makefile
:makefile echo <p> Username : %username% > info.html echo Section : %section% >> info.html echo phone# : %phone#% </p> >> info.html msg * Done! exit
I think that should do it. I'm not quite sure on the html though, that should make a standard paragrah if I remember correctly. Thank you. I had got as far as the input part, but you hav also solved the output. That should work great.
Thank you againCode: [Select]set /p correct=Was all this information correct(Y/N): if /i %correct%==n goto start if /i %correct%==y goto makefile what if user will press some other button ? i would change that to: Code: [Select]set /p correct=Was all this information correct(Y/N): if /I '%correct%' equ 'y' goto makefile goto start& echo the entered information on-screen before asking the question so that it can be checked...
Code: [Select]@echo off
:start cls set username= set section= set phone#= set correct=
cls SET/P username=Please enter your name: echo --------------------------------------------- SET/P section=Please enter your section: echo --------------------------------------------- SET/P phone#=Please enter your phone#: echo --------------------------------------------- set /p correct=Was all this information correct(Y/N): if /i "%correct%"=="n" goto start if /i "%correct%"=="y" goto makefile goto start
:makefile echo ^<p^> Username : %username% > info.html echo Section : %section% >> info.html echo phone# : %phone#% ^</p^> >> info.html msg * Done! exit
That's the improved version. Now it shows the information you typed so you can verify if it is correct. Quote :makefile echo <p> Username : %username% > info.html echo Section : %section% >> info.html echo phone# : %phone#% </p> >> info.html msg * Done! exit
< and > have special significance in the Echo command therefore cannot be used as literals unless they are ESCaped e.g. ^
Thanks, I fixed it.
|