Windows 7 .bat files for new users

#1
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
 


Last edited:

kaos

Senior Member
#3
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
I remember scamming my friend with shutdown -c. lol
 


AceInfinity

Senior Member
Microsoft MVP
#5
If you want to start notepad:
Code:
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.

"%ERRORLEVEL%"=="0"

Just means that no true error was returned.
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.