Jump to content

Help a noob with a simple .bat file. =)

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
s4nt0s123

s4nt0s123

    Newbie

  • Members
  • Pip
  • 7 posts
Hi I'm new here and I'm hoping to learn a lot from this forum. I just started learning simple batch file programming last night and found out its actually a lot of fun. If someone could please tell me why this isn't working that would be great. I'm just trying to put in a password and have it open the mplayer.exe

Thank,
Devin





@Echo off

set /p pas=Please type your password:
IF '%pas%' == 'toe' GOTO mplayerc.exe

:mplayer
"C:\Program Files (x86)\K-Lite Codec Pack\Media Player Classic\mplayerc.exe"

#2
s4nt0s123

s4nt0s123

    Newbie

  • Members
  • Pip
  • 7 posts
18 views and nobody knows? This should be a cakewalk for you guys. =)

#3
s4nt0s123

s4nt0s123

    Newbie

  • Members
  • Pip
  • 7 posts
Wow I just figured out if i type in the wrong password then it opens up the program but if I type in the right password nothing happens..I'm lost

#4
s4nt0s123

s4nt0s123

    Newbie

  • Members
  • Pip
  • 7 posts
Never mind i figured it out!

Original string:
IF '%pas%' == 'toe' GOTO mplayerc.exe

Working string:
IF '%pas%' ==toe GOTO mplayerc.exe

haha I feel stupid

#5
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
@Echo off

set /p pas=Please type your password:
IF '%pas%' == 'toe' GOTO mplayer

:mplayer
"C:\Program Files (x86)\K-Lite Codec Pack\Media Player Classic\mplayerc.exe"

when you pointed to goto you pointet to mplayerc.exe but your variable is mplayer :D
Posted Image

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Also, you need another goto after your IF statement so you won't launch mplayer anyway.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
s4nt0s123

s4nt0s123

    Newbie

  • Members
  • Pip
  • 7 posts
Thanks a lot for the feedback, I was wondering how i would do the next IF statement to make it so it wont open mplayer. How could I make it to where anything but the right password will close out the program or repeat Please type your password?

So I have this

set /p pas=Please type your password:
IF '%pas%' == 'toe' GOTO mplayer

So what do I use to make sure only the right password will work?

IF '%pas%' == '?' GOTO whatever I want =)

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
@Echo off

set /p pas=Please type your password:
IF '%pas%' == 'toe' GOTO mplayer
GOTO end

:mplayer
"C:\Program Files (x86)\K-Lite Codec Pack\Media Player Classic\mplayerc.exe"
:end
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog