Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I made this batch file, when typing y and n for the first time it works fine, but as soon as I choose n, every single time I try inputting something, it opens up the 7000 songs wpl list then closes it and replaces it with Rick Astley...

HELP!

@echo off
:Ask
echo Would you like to listen to the best songs out of the 7000 I have?(Y/N)
set INPUT=
set /P INPUT=Type input: %=%
If /I "%INPUT%"=="y" goto yes 
If /I "%INPUT%"=="n" goto lolno
echo Incorrect input & goto Ask
:yes
start c:/Users/MyName/Music/Playlists/"The Best of the 7000 songs that I have.wpl"
:lolno
start c:/Users/MyName/Music/Downloads/Music/"Various Artists"/"The Number One 80's Album Disc 2"/"06 Never Gonna Give You Up.mp3"
share|improve this question
    
looks like the location of " caused it. have you tried start "c:/Users/MyName/Music/Downloads/Music/Various Artists/The Number One 80's Album Disc 2/06 Never Gonna Give You Up.mp3"? –  PatricK Nov 6 '13 at 6:05

2 Answers 2

start uses the first quoted argument it encounters as the window title for a new cmd session. If you want to start anything that has spaces in it, you have to do it this way:

start "" "%UserProfile%\Music\Playlists\The Best of the 7000 songs that I have.wpl"

Also, use backslashes in cmd exclusively when dealing with paths as arguments to built-in commands. The Windows API is smart enough to translate slashes for you, but cmd uses / for switches and named arguments and its parser gets confused sometimes, so best avoid it.

share|improve this answer

The way labels work is it goes to that label and then continues downwards. With your example:

:yes
start c:/Users/MyName/Music/Playlists/"The Best of the 7000 songs that I have.wpl"
:lolno
start c:/Users/MyName/Music/Downloads/Music/"Various Artists"/"The Number One 80's Album Disc 2"/"06 Never Gonna Give You Up.mp3"

goto yes will run (jump to :yes and continue downwards):

:yes
start c:/Users/MyName/Music/Playlists/"The Best of the 7000 songs that I have.wpl"
:lolno
start c:/Users/MyName/Music/Downloads/Music/"Various Artists"/"The Number One 80's Album Disc 2"/"06 Never Gonna Give You Up.mp3"

goto lolno will run (jump to :lolno and continue downwards):

:lolno
start c:/Users/MyName/Music/Downloads/Music/"Various Artists"/"The Number One 80's Album Disc 2"/"06 Never Gonna Give You Up.mp3"

What you need to do is add either a goto :eof (eof means "end of file") or exit /b at the end of any label segment you don't intend to fall through:

:yes
start c:/Users/MyName/Music/Playlists/"The Best of the 7000 songs that I have.wpl"
goto :eof

:lolno
start c:/Users/MyName/Music/Downloads/Music/"Various Artists"/"The Number One 80's Album Disc 2"/"06 Never Gonna Give You Up.mp3"
goto :eof

Either command will end the script there. You could also define a different label under them to jump to, if you wanted.

share|improve this answer
    
Thank you heaps –  John Peters Nov 6 '13 at 6:38
    
Damn, I missed that one. That's what I get for answering questions in the morning ;) –  Joey Nov 6 '13 at 7:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.