Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » need help badly in batch (.bat)
Closed Thread
Old 11-12-2008, 09:27 PM   #1 (permalink)
 
Newb Techie

Join Date: Nov 2008

Posts: 19

ms-dos707 is on a distinguished road

Default need help badly in batch (.bat)

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

Last edited by ms-dos707; 11-12-2008 at 09:30 PM.
ms-dos707 is offline  
Old 11-13-2008, 12:23 AM   #2 (permalink)
Baez's Avatar
 

Join Date: Sep 2005

Location: Toronto, Canada

Posts: 5,466

Baez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of light

Default Re: need help badly in batch (.bat)

This is a fairly complex script. It would take a bit for me to type it out for you. There is this resource that desribes exactly what you are looking for: Batch files - Ask For User Input
__________________

Baez is offline  
Old 11-13-2008, 04:40 PM   #3 (permalink)
 
Newb Techie

Join Date: Nov 2008

Posts: 19

ms-dos707 is on a distinguished road

Default Re: need help badly in batch (.bat)

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...


Last edited by ms-dos707; 11-13-2008 at 04:43 PM.
ms-dos707 is offline  
Old 11-13-2008, 05:15 PM   #4 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default Re: need help badly in batch (.bat)

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
office politics is offline  
Old 11-13-2008, 05:27 PM   #5 (permalink)
 
Newb Techie

Join Date: Nov 2008

Posts: 19

ms-dos707 is on a distinguished road

Default Re: need help badly in batch (.bat)

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

Last edited by ms-dos707; 11-13-2008 at 09:47 PM.
ms-dos707 is offline  
Old 11-14-2008, 02:02 AM   #6 (permalink)
Baez's Avatar
 

Join Date: Sep 2005

Location: Toronto, Canada

Posts: 5,466

Baez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of light

Default Re: need help badly in batch (.bat)

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.
__________________

Baez is offline  
Old 11-14-2008, 09:07 AM   #7 (permalink)
 
Newb Techie

Join Date: Nov 2008

Posts: 19

ms-dos707 is on a distinguished road

Default Re: need help badly in batch (.bat)

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

Last edited by ms-dos707; 11-14-2008 at 09:10 AM.
ms-dos707 is offline  
Old 11-15-2008, 07:35 PM   #8 (permalink)
 
Newb Techie

Join Date: Nov 2008

Posts: 19

ms-dos707 is on a distinguished road

Default Re: need help badly in batch (.bat)

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
ms-dos707 is offline  
Old 11-15-2008, 10:41 PM   #9 (permalink)
Saxon's Avatar
 

Join Date: Feb 2007

Posts: 6,362

Saxon is just really niceSaxon is just really niceSaxon is just really niceSaxon is just really nice

Default Re: need help badly in batch (.bat)

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.
__________________
I am not here for long I am deploying soon so please don't expect anything long winded.

Saxon is offline  
Old 11-16-2008, 11:02 PM   #10 (permalink)
 
Newb Techie

Join Date: Nov 2008

Posts: 19

ms-dos707 is on a distinguished road

Default Re: need help badly in batch (.bat)

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

Last edited by ms-dos707; 11-17-2008 at 05:40 PM.
ms-dos707 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
controlling windows batch files tmshort Programming Discussions 3 09-09-2008 01:52 PM
bad batch q6600? nukeman8 Building, Buying, or Upgrading High Performance PC Systems 49 09-04-2008 11:42 AM
Help with a Dos batch file Jakes55 Programming Discussions 2 03-02-2008 09:04 PM
Batch scripting: Startup applications and close batch file LincolnX Windows Operating Systems and Software 7 01-17-2008 08:50 PM
Batch? Yek Programming Discussions 3 10-28-2007 03:19 PM