Windows Batch Scripting for Beginners and how to use it.

What is a Batch file?

Most people will never really understanding what the extension .bat is in Windows or even DOS.  However it is something that is native to programmers around the world because it is the first thing most people who make programs or works with scripting start to use way before they do anything else.  It should be considered the first linguistic languages that is very powerful.  It is designed to be used in DOS but can also be used in Windows as a DOS command easily and effectively through Windows OS.   Some of these are what you should explore even more to learn how to program and create scripts even more.  However this blog post is just a introduction into doing it and how you can use this in your everyday IT Job.

According to Wikipedia:

A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching.

Understanding scripting is the first part in creating powerful scripts for everyday use.  However, I am one of the few to use the help command in DOS:

HELP [command]

This is a good tool for those who might want to explore the power of using a Batch to get your job done or to creating a batch file because you will need to know what you can use in the batch file.

Here are a few commands you might want to use in a batch file:

  • SET /P variable=[promptString]
  • Start of the batch file ECHO OFF and ECHO ON after the batch file is complete.
  • If and THEN (Wikipedia)
  • CALL filename.bat

Creating Batch files

I’m not going to go into much details about creating the batch in the way you might need but I will be talking about this in general about ways you can create a batch and which programs are good at helping you create a batch file.

First you need a program to create it.  You can always use Wordpad or Notepad but you could find it isnt’ a good as Notepad ++.   I have used it in the past for programming in many different programming languages such as Pascal, C++, COBOL, and SHELL Scripting.  I’ve talked about SHELL scripting in past for LINUX which you can use Notepad++ for it also to create Linux shell scripting.  I will say you can do a lot with the open-sourced program that is free to use.  So I always want to use this with anything I am doing because it shows you where you might have a problem in your scripting language and helps you identify how to fix it.  You’re best advice is to just try to think about what you want to accomplish with a batch file and start thinking logically about how you would do that.

You will need to make sure the .batextension is on the file name.  Make the filename something that you can easily run in DOS because you don’t want to make the batch file anything complicated because that might not work properly if you use a call command in another batch file.  So consider the naming convention of your batch file(s).

Trial and Error

After creating the batch file you will need to do some trial and error test to make sure it will work with what you need to use it for and also make sure there isn’t something unexpected.   This is what programmers do all the time by compiling  the program and running it on different systems to see what it will do in different Windows environments.

Finally, You will see that you can do so much more with a batch that you previously did and it can be a great asset in doing repetitive stuff at work or at home.   If you do this right it can even help speed up your life.   Here are a few Blog posts that I have talked about previous:

As you can see these will help you understanding scripting but also help you to figure out what you might want to do with a Batch and why you might need to create a batch file.  Even I know this is only a few blog post that will at least hopefully give you even more ideas on what will help you to create batch files.

Don’t forget to like and subscribe to my blog page for even more updates.   Do you have a favorite DOS command?  why not share it with others so they can learn even more.

TINYURL being used by scammers and hackers — How to prevent it!!

With Phishing attempts going on with the TINYURL redirect website, I thought I would show you how you could prevent from going to a site you don’t want. Tinyurl.com has a great little feature, although it is a feature based on your cookies. It however will help prevent you from going to a site that you don’t know anything that about. It’s called the Preview Feature, and is available to any user who wants to use it.

previewtiny

As you can see if you enable it and you go to a click on a tinyurl, you will see this:

http://tinyurl.com/6t7ukk

previewtiny1

[ad#ad2-right]As you can see, if you click any TINYURL links you will automatically be told where that link is redirecting you to. This however only works with there being a cookie left behind in your system to let tell Tinyurl that is has to show the link first. So if you clean your cookies out from time to time, you will need to enable it every time after you clean the browser cookies. This will help prevent you from being phished because you will be able to tell if it is the right site in the first place. If not then you don’t have to visit that site. This should be enabled on all Short URL Sites, I hope they make it a mandatory for any site that redirects. This would help stop phishing and scammers because they can’t hide behind unknown url. Only time will tell though, these sites are always going to have problems but this would solve so many problems.

Being a Bad BOT!

badbot1

I had the strangest thing happen today, Seemed a Bad Bot was Crawling my pages. I was getting at least 60 page views an hour from this bad Bot!! The individual IP’s of this Bad Are:

65.208.151.112
65.208.151.113
65.208.151.114
65.208.151.115
65.208.151.116
65.208.151.117
65.208.151.118
65.208.151.119

[ad#ad2-right]After the first initial hour of this going on, I started wondering what this bot was doing.   I did some more research into this little bot.   I did find out it is owned by Kintiskton LLC.  (Twitter Search)

Anyways It bothers me that when you do a Google Search for this company, it comes back with no company.  Some people have already did there research and have come up with very little.

I dug even more and some are saying this might be Homeland Security, and I have my own thoughts on this.   I might be paranoid myself but if there is no company out there and the IP keeps coming back, I assume it is BAD mojo.  Some people worry that it is a hacker probing for vulnerabilities and that worried me.

I decided with the Help from Godaddy, to ban the lot of IPs.  I figure someone is trying to get information or trying something they shouldn’t, I’ll stop it myself.   If you have WordPress and are also having problems with this ip, you can ban it by adding this to your HtAccess file:

order allow,deny
deny from 65.208.151.112
deny from 65.208.151.113
deny from 65.208.151.114
deny from 65.208.151.115
deny from 65.208.151.116
deny from 65.208.151.117
deny from 65.208.151.118
deny from 65.208.151.119
allow from all

This is how you block those ip in the HtAccess file. Thanks to WordPress for showing me how.

Using Skype with Cellular BroadBand Modems

If your like me you will want to make sure you have the best possible speed and connection with your broad band modem. Here are a few articles to better help with you get the best possible speed with a broad band modem like a Cricket modem:

Some other things to consider are:

These will start to make it better for you to use a modem and get the best possible speeds from the modem.  You have to realize what your coverage area is.  There are many factors in regards to your modem speed but that is something that you will have to figure out how to get better speeds.

How do you use Skype with your Cellular broad band modem?

Somethings to remembers with your broadband modem is you won’t have a good connection no matter how hard you try.   Most cellular carriers don’t want you to us it with VOIP(Voice of Internet Protocol).   So you will have to pay close attention to how you use the bandwidth and what you are doing while making a VOIP call.

The good thing about Skype is, it comes with some very useful tools to better watch your bandwidth and to help get the best possible connection.  You will want to make sure not to have it be a super-node, to do this you go to:

Tools then;Options

My settings for Skype with Cricket<

As you can see I checked off use port 80 and 443 as alternative incoming connections, I also like to see all the technical information and bandwidth usage per call.  I made sure to use Socks5 to prevent skype from becoming a super-node. I also have it set to not automatically start up when I load windows.  To do that all you have to do is go to the General tab and un-check start Skype when Windows start.   You can use any port you want as long as you use the same on the SOCKs5 setting also.   I just made the port up it can be 0 to 4 numbers long.   If you want to understand what ports are this little document will greatly help you figure out which ports are good to use.  Some other things to remember when you use Skype for long periods of time is if you need to call someone you should try not to use the internet to much for that takes bandwidth also.  It is better to have Skype use all the possible bandwidth you have available.

Disaster preparation 101 — Data backup

In this one I will talk about Disaster, it happens to all of us from time to time. A fire, a earthquake, a stolen laptop or any number of ways. So what happens to your data, is it stored on the laptop? Is it important very sensitive data? Could you get fired if you lost that data?

[ad#ad2-right]These are all questions you must ask yourself when you have laptop. How do you backup your data or even do you have a backup? Having seen this with my own clients, I must wonder if there are people out there who just don’t care. I had a client the other day who gotten a virus and this was a really mean virus. Deleted some very important files when you tried to clean the virus out. She called me in a panic because she couldn’t load up windows? I asked if she had any backups, she said “what’s a backup” . So I sat there discussing this with the client for over 20 minutes. Finally she started to understand, she said she had the OEM Backup DVD but nothing else. She also said she needed help with getting data off the computer. I told her that I would be able to come the next day and I was lucky the virus didn’t do anything else to her data. We were able to retrieve the data from her system. That is where I start my rant , Why would anyone not have backup of there most important data?

So How do you backup your data? This is controversial and somewhat depends on how much people want to spend to keep there data safe and not loose pictures or music. There are several ways to do it, each way has it’s pitfalls or short comings and requires a little more effort:

Kinds of Backup

Hard Medium – DVD, CD, External Hard drive

Although,  The hard medium is usually used that doesn’t mean you can have a backup other than hard.   Here are some ways to back up on the internet.

Internet Medium:

  • Jungle Disk — Provides online storage through the Amazon s3 service.   Only pay for what you use.   It works well with most Operating system.  I’ve used it on Vista so it is really nice.
  • Carbonite Online backup –Another good Online storage.
  • Some Other Online backup — Here a list from Amazon to better help you find the type of software that you might need.

These are just a few options, if you want to look for other you can.  The important thing to do is BACKUP because if you need some data that gets wiped or destroyed.  You will be kicking yourself for not backing up.