Jump to content

Needs some batch file help

MrPete1985

I am trying to make a batch file that will go to a defualt label but I am not sure how to do it.

 

Here is some of my code

echo option 1echo option 2 set /p choice= "make your selection: "goto %choice%goto done :aecho entered A :becho entered B :donepause

If the user enters a choise that is invalid I get a message that the lable does not exist and the batch file ends it does not run the done label and the window closes before the user can read the error.

Link to comment
Share on other sites

Link to post
Share on other sites

To my knowledge the only way to fix what you're having is to do this:
 

@[member=Echo] off:mainclsecho option 1echo option 2 set /p choice= "make your selection: "if %choice% == 1 goto aif %choice% == 2 goto bgoto done :aecho entered Apausegoto main :becho entered Bpausegoto main :donepause

I added @Echo off because without it, it seems messy :T And I added the menu as a label so you can go back to that after making a choice.
From what I gathered, this is essentially what you wanted?

Link to comment
Share on other sites

Link to post
Share on other sites

That looks like it will work, I am making a batch file to run check sums on some files for work and I was hoping to avoid 16 if statments

 

EDIT: I already have the @Echo off in my file just didn't paste it in here

Link to comment
Share on other sites

Link to post
Share on other sites

That looks like it will work, I am making a batch file to run check sums on some files for work and I was hoping to avoid 16 if statments

 

EDIT: I already have the @Echo off in my file just didn't paste it in here

I'm not sure there's another method, select case won't help either.

I inherently won't be of much help from here on in, so goodluck :P

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×