|
Answer» Is it possible to create a U.I. with a batch file? Basically something like you would see when installing a program?
Just wondering....
Thanks, -bMI do not know what you see when installing a program. My experience varies with what is being installed, and the creator.
If you start the computer in SAFE mode, you get a U.I. offering a choice of what you want it to do.
That sort of U.I. can be done with a batch file - in fact the SAFE mode U.I. might even be controlled by a batch file on some versions of Windows.
A "G.U.I." is a Graphics User Interface - I think it most unlikely that you could simulate a "windows" type of pretty coloured graphics and Mouse control.
Regards Alan I don't fully understand what you mean, but from what I understand it as, do you mean something like this? Code: [Select]@echo off echo. echo =================================== echo = Basic GUI = echo =================================== echo = = echo = Installing... = echo = = echo =================================== pause >nul
Be sure to copy it into notepad (to automatically sort the spacing out).Hi
If you want INTERACTION between Computer and User you also need a way for the User to talk back to the computer.
To illustrate, these 6 lines I have just grabbed out of a 150 start up control file.
Code: [Select]FC %~n0.txt %~n0.cfg && goto HOP0 echo ERROR E E E E E E E ERROR SET /P ANS="*.TXT and *.CFG mis-match. Update CFG ? Y(es) / N(o) :" if /I %ANS%#==Y# COPY %~n0.txt %~n0.cfg :HOP0 DEL %~n0.txt
Line 1 compares a temporary file %~n0.txt with a "master" reference %~n0.cfg AND AND ( && ) if they match it jumps to HOP0 (line 5) Otherwise ERROR is reported and the user is asked whether or not to update the *.CFG, which determines whether the file is copied
Finally, either way, Line 6 deletes %~n0.txt for which there is no further use, and then a lot more code launches other applications etc.
You will find many examples of user input if you search for "SET /P" and "CHOICE", but messages / questions from the computer are no prettier than Jacob's suggestion, and user input is via the keyboard, not the mouse.
nb If you want the batch file to use the mouse for input you probably need to find a suitable third party application (or possibly VBS); but if the anti-virus needs an urgent decision upon a NEW hazard - how can you shift focus if the batch file controls the mouse ?
Regards Alan if you want it like a true U.I. there are some old batch programs that can be used by batch files to make menus and control them by use of keyboard or mouse. this site has plenty of batch programs you can get. hope this worksThanks a lot for the replies! I really appreciate everyone's help. If I would have had my code completely finished before I decided to post this thread than all you guys would have UNDERSTOOD exactly what I was trying to do. So here is my batch file code (as of now):
Code: [Select]@ECHO OFF ECHO Would you like to backup your SLMHEAT drivers.txt? If so... PAUSE copy "C:\Program Files\Hasbro Interactive\NASCAR Heat\SLMHeat\drivers.txt" "C:\Program Files\Hasbro Interactive\NASCAR Heat\SLMHeat\olddriversBACKUP.txt" copy "C:\Program Files\Hasbro Interactive\NASCAR Heat\SLMHeat\drivers.txt" before_car.txt ECHO Would you like to add the custom car to your SLMHeat drivers.txt? If so... PAUSE copy car.txt+before_car.txt drivers.txt copy drivers.txt "C:\Program Files\Hasbro Interactive\NASCAR Heat\SLMHeat" del drivers.txt ECHO Would you like to copy the custom car.TEX file to your SLMHeat folder? If so... PAUSE copy *.tex "C:\Program Files\Hasbro Interactive\NASCAR Heat\SLMHeat"
Thanks to SideWinder, Jacob, and my very small batch file vocabulary I have completed what I was trying to accomplish. Now I want to take it a step further and make it easier for the average Joe !
When you compile the code into a .BAT file you'll see that the user has no choice but to run the bat file completely or exit the program. I would just like to add a Yes or No to all 3 questions in my batch file (for now).
Here are the questions in my batch file: Code: [Select][b]Question #1:[/b] ECHO Would you like to backup your SLMHEAT drivers.txt? If so... PAUSE [b]Question #2:[/b] ECHO Would you like to add the custom car to your SLMHeat drivers.txt? If so... PAUSE [b]Question #3:[/b] ECHO Would you like to copy the custom car.TEX file to your SLMHeat folder? If so... PAUSE
NOTE: The only options the user has when asked questions is to hit enter or close the program. Like I said above, all I would like to add now is the option for the user to choose yes or no on each question.
Also: If someone could point me in the direction to a "batch file dictionary" that would show and explain all the commands that can be used in .BAT file creation then I could stop bothering you all so much. LOL
Any help would be greatly appreciated!
Thanks, -bM
Proud Staff @ SSDevelopment.NET Hi
I suggest the following technique
Code: [Select]SET /P ANS="Message/Question from computer to user" IF /I "%ANS%" NEQ "Y" EXIT
The first of your questions would be :- Code: [Select]"Would you like to backup your SLMHEAT drivers.txt? Y(es) / N(o) :"
That gives the user the choice of "Y" or "N" You can give extra guidance such as a reminder to hit "Enter" etc.
The second line of code looks for "Y". The /I argument also accepts lower case "y". If the user responds with "Y" or "y" the code continues to perform the script which follows. For any other RESPONSE (including but not restricted to "N") the script aborts with EXIT.
A simple 4 line alternative :- Code: [Select]:LOOP1 SET /P ANS="Message/Question from computer to user" IF /I "%ANS%"=="N" EXIT IF /I "%ANS%" NEQ "Y" LOOP1
Please note that LOOP1 is used for only the first question. Each question must have a DIFFERENT label, such as LOOP2, LOOP3, etc.
This has the extra feature that the question is repeated for wrong response, such as "Y(es)". It will only accept and use "Y", "y", "N", "n". Whether this feature is a blessing or a curse depends upon how much effort the user has to put into logging on and doing whatever launches this script.
Regards Alan Great Alan, sorry bMowl, I didn't understand. You can also use an add-on which gets the ID of the key pressed, which you can use to create a menu without the need to press enter. This add-on can be generate by the batch file itself so there is no need for a user to download another file. Please see this example. Code: [Select]@echo off if not exist C:\WINDOWS\getkey.com ( echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>C:\WINDOWS\getkey.com echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>C:\WINDOWS\getkey.com echo l/[emailprotected]>>C:\WINDOWS\getkey.com ) :loop C:\WINDOWS\getkey.com set key=%errorlevel% echo Key ID you pressed is %key%. goto loop I have make a simple program that have interface close to real GUI (graphical user interface) this program is a Antivirus
i use "xecho.exe" to display a colored message.
|