need help badly in batch (.bat)

Status
Not open for further replies.

ms-dos707

Solid State Member
Messages
19
Okay i want to know how to make a batch file that has like an option menu but it asks you what file you want to copy
and where you want to drop the copy
and im not shure if this is possible
but i want it to be so that for example

-----------------------------------------------------
| |
| what do you want to copy? example.txt |
| |
| |
| |
| |
| |
| |
| |
| where do u want to place the copy? desktop |
| |
| ______________________________________________


so that you type what file and where to put it
with out the c://documents and settings/user/desktop
so like
xcopy [source] [destination] and all you would have to type in is the file name and for dest the folder
 
i dont get it..... umm ill just post my code
dont laugh my friend wanted the password and the progress bar and the corny crap


Code:
@echo off
:pssw
echo Access Data Files
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
set input=
set /p input= Enter password to continue...
if /I %input%==028708 goto A
if /I %input%==E goto E
cls
echo Inccorect password!
pause  
Goto passwordmenu
:A
cls
echo password correct!
pause
echo Now Accessing data files
cls
goto percentpercent
:E
exit
:percentpercent
echo.
echo.
echo.
pause
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ²²²²²²²²²²²²²²²²²²²² 1%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: Û²²²²²²²²²²²²²²²²²²² 3%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: Û²²²²²²²²²²²²²²²²²²² 5%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛ²²²²²²²²²²²²²²²²²² 10%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛ²²²²²²²²²²²²²²²²² 15%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛ²²²²²²²²²²²²²²²² 20%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛ²²²²²²²²²²²²²²² 25%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛ²²²²²²²²²²²²²² 30%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛ²²²²²²²²²²²²² 35%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛ²²²²²²²²²²²² 40%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛ²²²²²²²²²²² 45%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛ²²²²²²²²²² 50%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛ²²²²²²²²² 55%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²²²² 60%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²²² 65%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²² 70%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²² 80%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²² 85%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²² 90%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ² 95%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%%
echo ----------------------------------
GOTO END

:END
cls
echo.
echo.
echo loading complet...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%%
echo ----------------------------------
echo.
pause
cls
goto ppmenu
:PPmenu
echo Type Y to download file
echo Type N to exit the download 


set /p input= Option-
if /I %input%==n goto E
if /I %input%==y goto D
cls 
echo Invalid command
goto PPmenu
:D
obviously this part is not done yet...
 
just use arguments. its much easier

batch files have variables %1, %2, %3 and so on. These are defined by the command that is executed when you execute the command.

For example,

command: filename.bat one two three

variables:
%1 = one
%2 = two
%3 = three


Code:
echo source: %1
echo dest: %2

xcopy %1 %2

if you want progress bars, download and install robocopy
 
these progress bars work fine test it if you dont believe me.....
and no its much more efficent if its user input because you could chose whatever file
and where to put it (at least from what i under stand)
tell me if i dont understand at all what you are trying to teach me
sorry if i dont




EDIT:i dont get this whole concept of using arguments can u please explain further
EDIT:i got this in a ms-dos shell- invalid number of paremeters
 
Does this have to be done in a batch file or can I write a simple C program you can compile and run? Much more simple to do this in programming instead of scripting.
 
ummm well the whole point of this is so that i can learn from experience and other people
i really want to learn a scripting and or a programming language so i can go into that field
BTW i appreciate the offer for you to write me a C program
and yes it has to be in batch
 
here is my code
Code:
@echo off
:pssw
echo Access Data Files
set /p input=Enter password to continue...
if %input%==028708 goto A
if /I %input%==E goto E
cls
echo Inccorect password!
pause > nul  
Goto passwordmenu
:A
cls
echo password correct!
pause
echo Now Accessing data files
cls
goto percentpercent
:E
exit
:percentpercent
echo.
echo.
echo.
pause
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ²²²²²²²²²²²²²²²²²²²² 1%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: Û²²²²²²²²²²²²²²²²²²² 3%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: Û²²²²²²²²²²²²²²²²²²² 8%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛ²²²²²²²²²²²²²²²²²² 20%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛ²²²²²²²²²²²²²²²²² 21%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛ²²²²²²²²²²²²²²²² 29%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛ²²²²²²²²²²²²²²² 30%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛ²²²²²²²²²²²²²² 36%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛ²²²²²²²²²²²²² 37%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛ²²²²²²²²²²²² 45%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛ²²²²²²²²²²² 47%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛ²²²²²²²²²² 53%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛ²²²²²²²²² 59%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²²²² 68%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²²² 76%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²² 79%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²² 83%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²² 85%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²² 91%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ² 99%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo loading...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%%
echo ----------------------------------
GOTO END
:END
cls
echo.
echo.
echo loading complete...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%%
echo ----------------------------------
echo.
pause
cls
goto ppmenu
:PPmenu
echo Type Y to download file
echo Type N to exit the download 
echo.
echo.
set /p input= Option-
if /I %input%==n goto E
if /I %input%==y goto D
cls 
echo Invalid command
goto PPmenu
:D
echo.
echo.
echo.
echo.
echo.
echo.
pause
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ²²²²²²²²²²²²²²²²²²²² 1%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: Û²²²²²²²²²²²²²²²²²²² 3%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: Û²²²²²²²²²²²²²²²²²²² 9%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛ²²²²²²²²²²²²²²²²²² 20%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛ²²²²²²²²²²²²²²²²² 21%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛ²²²²²²²²²²²²²²²² 25%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛ²²²²²²²²²²²²²²² 26%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛ²²²²²²²²²²²²²² 33%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛ²²²²²²²²²²²²² 41%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛ²²²²²²²²²²²² 46%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛ²²²²²²²²²²² 49%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛ²²²²²²²²²² 54%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛ²²²²²²²²² 55%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo ldownloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²²²² 62%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²²² 69%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²²²² 72%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²²² 81%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²²² 86%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ²² 95%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ² 96%%
echo ----------------------------------
ping -n 3 localhost >NUL
cls
echo.
echo.
echo downloading file...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%%
echo ----------------------------------
GOTO END

:END
cls
echo.
echo.
echo downloading complete...
echo ----------------------------------
echo Progress: ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%%
echo ----------------------------------
goto userinput
now im getting errors in the shell that i need to figure out but i cant...
and yes it needs to be batch
so can i please have help with user input my project is due monday
and yes this is for high school
i dont want to sound rude but im in a rush
thankyou
- ms-dos707
 
Don't take this the worng way but we wont do your home work for you, we don't mind pointing you in the right direction but we will not do your home work for you, we don't mind pointing you in the right direction.

I am assuming you where passed course material, and you obviously have a internet connection there is lot's of .bat tutorials out there, if you look for them there will be directions on how to acomplish what you are trying to do.
 
okay... thankyou i figured it out

but i still need to figure out why it keeps on closing when i press enter and not going to incorrect password
this happens in all the option menus i make
this ****es me off because i know there is something im doing wrong and i cant figure out whats wrong
please help!
can u please help!
i open it up in a ms-dos shell and it says goto is unexpected at this time
 
Status
Not open for further replies.
Back
Top Bottom