+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, Ok Please point out what I'm doing wrong with IF command in Coding and Web Development; Ok I'm sure I’m being thick but I can’t get this to work correctly its always putting out a true ...
  1. #1

    Join Date
    Dec 2007
    Location
    Nottinghamshire
    Posts
    148
    Thank Post
    50
    Thanked 14 Times in 14 Posts
    Rep Power
    11

    Ok Please point out what I'm doing wrong with IF command

    Ok I'm sure I’m being thick but I can’t get this to work correctly its always putting out a true value even though the variable is wrong and I haven't a clue why

    set Sophos=
    set /P Sophos=To run Sophos type Y otherwise type N: %=%
    if /i "%sophos%" ==Y goto RunSophos
    ELSE goto SkipSophos
    Echo "Fail" >>c:\test
    :Runsophos
    Echo "run" >>c:\test.txt
    Echo "%sophos%" >>c:\test.txt
    goto EndSohpos
    :SkipSophos
    echo "skip" >>c:\test.txt
    Echo "%sophos%" >>c:\test.txt
    goto EndSophos
    :EndSophos
    echo "end" >>c:\test.txt
    The text output is just for testing. Whenever you look in the text file it has always ran runsophos even if you have put N in

    Any help would be appreciated

  2. #2

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    60
    Code:
    set /p sophos=Enter Y or N
    echo %Sophos%
    pause
    if /i %sophos% EQU y (goto moo) else (goto boo)
    :moo
    echo moo
    goto endbat
    :boo
    echo boo
    goto endbat
    :endbat
    echo done
    pause
    Works for me - sorry, didn't have time to rejig yours but that should be apparent what's what.

  3. Thanks to OutToLunch from:

    notalot (13th May 2009)

  4. #3

    Join Date
    Dec 2007
    Location
    Nottinghamshire
    Posts
    148
    Thank Post
    50
    Thanked 14 Times in 14 Posts
    Rep Power
    11
    thanks for that

SHARE:
+ Post New Thread

Similar Threads

  1. Point to point network speed test tools
    By tarquel in forum Networks
    Replies: 13
    Last Post: 10th May 2010, 01:59 PM
  2. [Video] He's got a point....
    By mattx in forum Jokes/Interweb Things
    Replies: 0
    Last Post: 14th April 2009, 12:38 PM
  3. What's the point
    By laserblazer in forum General Chat
    Replies: 8
    Last Post: 7th February 2008, 07:49 PM
  4. Point to Point Bandwidth Test
    By ICTNUT in forum How do you do....it?
    Replies: 1
    Last Post: 10th September 2007, 02:14 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •