need help badly in batch (.bat) - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Software > Programming
Click Here to Login
Closed Thread
 
Thread Tools Display Modes
 
Old 11-12-2008, 08:27 PM   #1 (permalink)
Newb Techie
 
Join Date: Nov 2008
Posts: 19
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
__________________

__________________
ms-dos707 is offline  
Old 11-12-2008, 11:23 PM   #2 (permalink)

Triforcer
 
Baez's Avatar
 
Join Date: Sep 2005
Location: Toronto, Canada
Posts: 6,988
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, 03:40 PM   #3 (permalink)
Newb Techie
 
Join Date: Nov 2008
Posts: 19
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...
__________________
ms-dos707 is offline  
Old 11-13-2008, 04:15 PM   #4 (permalink)
It's all just 1s and 0s
 
office politics's Avatar
 
Join Date: Jan 2004
Location: in the lab
Posts: 6,555
Send a message via MSN to office politics
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, 04:27 PM   #5 (permalink)
Newb Techie
 
Join Date: Nov 2008
Posts: 19
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
__________________
ms-dos707 is offline  
Old 11-14-2008, 01:02 AM   #6 (permalink)

Triforcer
 
Baez's Avatar
 
Join Date: Sep 2005
Location: Toronto, Canada
Posts: 6,988
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, 08:07 AM   #7 (permalink)
Newb Techie
 
Join Date: Nov 2008
Posts: 19
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
__________________
ms-dos707 is offline  
Old 11-15-2008, 06:35 PM   #8 (permalink)
Newb Techie
 
Join Date: Nov 2008
Posts: 19
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, 09:41 PM   #9 (permalink)
Lord Techie
 
Kharn's Avatar
 
Join Date: Feb 2007
Posts: 7,638
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.
__________________
Visit this and do something for the world!
www.hackersforcharity.org

Want to do even more? Take a look here and join the fight on human trafficking.

Hear and you forget, see and you remember, do and you understand.

Kharn is offline  
Old 11-16-2008, 10:02 PM   #10 (permalink)
Newb Techie
 
Join Date: Nov 2008
Posts: 19
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
__________________

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


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



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 12:03 PM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.