Windows 7 .bat files for new users

Discussion in 'Programming and Scripting' started by travisthedrumer, Nov 13, 2010.

  1. travisthedrumer

    travisthedrumer New Member

    Nov 13, 2010
    Likes Received:
    So, I just got Windows 7, and I love it more than I love Linux. I think it was the ads for it. -.-

    When I had XP, I learned how to make simple batch files. nothing major, just something to bid my time while in class.

    I just mastered the "IF" command, and now I want to try and see if I can expand on that.

    IF EXIST C:\Users\Travis\Documents\Batchfiles\oinker.txt (
    del C:\Users\Travis\Documents\Batchfiles\oinker.txt
    ) ELSE (
    echo Delete function is a failure.

    that's what i have, and mind you, I am not a programmer by any means. I just love computers and google is my friend.

    I want to make the if command search for an running program, say notepad.exe. What would be the command for that?

    And can someone explain ERRORLEVEL to me? All I can find on google or anywhere else is what it does, but I dont understand the meanings of 1,2,3....

    Any help would be appreciated. :D

    Like I said, no programmer, just a mechanical engineering student who gets bored in math class.

    ALSO:: this is all being in notepad. no special programs, just notepad
    #1 travisthedrumer, Nov 13, 2010
    Last edited: Nov 13, 2010
  2. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Aug 3, 2010
    Likes Received:
  3. kaos

    kaos Senior Member

    May 9, 2011
    Likes Received:
    therer is loads you can do with basic programming, some fun stuff too, i got a fair few commands n programs i wrote such as creating a login with user name and passwword then if you get it right it can take you to list of commands you can write or if you get the username and password wrong it can execute other commands

    the options are endless

    let me no if you want help with ,bat files.... i understand that thy can be usefull and feel really good when you completed your own little scripts
  4. msfanboy98

    msfanboy98 New Member

    May 11, 2011
    Likes Received:
    I remember scamming my friend with shutdown -c. lol
  5. AceInfinity

    AceInfinity Senior Member
    Microsoft MVP

    Aug 12, 2011
    Likes Received:
    If you want to start notepad:
    start notepad.exe
    No need for a filepath because it's in the %SystemRoot% directory.

    If you're going to be using the ErrorLevel variable, you want to be saving your script with the .cmd file extension instead so that it gets executed first.


    Just means that no true error was returned.

Share This Page