The Infinite Loop – Beginner's SEO, Beginner C# & JQuery Tutorials Problem. Problem Solved. Loop. – The life of a programmer

24May/100

HostGator Discount Code 2010 – Cheap Web Hosting

By far one of the best hosting companies I have had the experience of being a customer of is HostGator. Their prices are extremely affordable and their customer support is SUPERB. I have never had a web hosting company with the technical expertise and patience of the live support chat. They always answer questions and help configure servers. I have had live support chat agents sit there patiently and wait for me to re-test my site after their changes.

Our programming company uses HostGator to host all of our sites - they have shared web hosting, reseller accounts, and others.
They offer UNLIMITED disk space hosting (250,000 files maximum ...100,000 if you intend to use the auto-backup feature) and
UNLIMITED bandwidth and are just the best hosting company i have ever had the pleasure of working with.

Use one of these HostGator 2010 coupon codes to receive $9.94 off your first month!

HostGator Discount Coupons/Promo Codes:

HostGator 2010 coupon/promo code 1: 994offhgpackage
HostGator 2010 coupon/promo code 2: 2010hostgatorcoupon
HostGator 2010 coupon/promo code 3: hostgatorcoupon2010
With the "BABY" plan for 1 month this means you pay $0.01 for 1 month hosting!

24Apr/102

How To Remove Viruses and Spyware Manually

Remove Viruses and Spyware Manually

Viruses,spyware, malware - whatever you want to call it, these things wreak havoc on your computer. Browser hijacks, file deletion, disabling ctrl+alt+delete are just a few things that some of these baddies can do. However, there are some tools to help you remove viruses and spyware manually.

Preventing Viruses and Spyware

Prevention is the best medicine. I'm sure you've heard something like that before but its true. Knowing about how to prevent spyware goes a long way. There are many programs that offer virus+spyware/malware protection and they will monitor your computer for changes to  your registry and files. I recommend the following programs for spyware/malware protection and scans.

Spyware Search & Destroy (Spybot S&D)

Ad-aware SE (Free for personal use)

Malware Bytes

Steps To Remove Viruses and Spyware Manually

  1. Download and Update 1 of the above software (or all 3! [recommended])
  2. Perform scans - Use the above programs to perform viruses, spyware, and adware scans. This is usually the initial step in removal as it will remove most of the spyware/adware/malware on your computer.  I recommend using safe mode to do these scans. In safe mode, your computer does not load extra applications and drivers, only the bare minimum need to run  your operating system, so these programs will have an easier time removing/deleting files from these viruses. There are different ways to get into Windows Safe Mode. On my computer, I turn off the power and turn the computer on. I keep hitting the F5 key until i get a prompt asking how I want to boot. I select safe mode and let it load. On your computer it may be a different F  key...like F7.
  3. Check your startup using  msconfig - Now that we have run scans and have done an initial clean on our computer. We can check our startup. Hit Start, then Run and type msconfig. Hit OK. Click the Startup tab, and look through the list. For the most part, anything here can really be unchecked. Try to look at the file path and the name of the checked items, this will usually give you a hint of what is what. Example: Logitech Quickcam Driver -> This is probably your camera driver, dont disable it. Once you go through the list and uncheck unwated items, click apply. Restart when you are prompted to. After restarting, click Do Not Show This Message Again and click OK.
  4. HijackThis! - Download Hijack This Hijack This is a program that will scan your computer and show information about changes that have been made to it. Download and install hijack this and run a scan and produce a log. You can copy and paste your log into this site: http://hjt.networktechs.com/ and it will guide you onto what to remove (To remove items, place checks next to them and click Fix Selected Issues) .  Also, there are many forums which will let you paste a HJT log and other kind users will help you analyze it. Alternatively, you can post your HJT log in the comments below and I will try to assist you with it.
  5. CC Cleaner  - Download CC Cleaner CC Cleaner will help remove temporary browser files, cookies, recycle bin, some program cache info. It is a good idea to run this program every once in a while just to help free up some space and keep your programs running in top shape.
  6. Reformat (Last Resort/First Resort) - A lot of viruses and spyware can be removed with the above steps, however, sometimes you get very pesky viruses and programs.  If you think the malware/adware/virus will be extremely difficult to remove, or if it is extremely malicious (i.e rootkit viruses that attach to windows files) sometimes the BEST option is to reformat and reinstall windows. This is the ONLY way to ensure your computer is COMPLETELY free of spyware. The programs listed above often do the trick. Sometimes you will do Steps 1-5 and then decide to reformat anyways because they couldn't completely remove the infection. Sometimes when I get extremely pesky infections, I reformat as my first resort. A backup, reformat and reinstall of all my programs takes me less than 4hours. Sometimes, virus removal and infection cleaning takes more than this.



Hope this guide helps you remove viruses and spyware infections. I often get paid to clean and remove spyware, adware, and viruses, however, I don't mind sharing how I do it. Most people just cant be bothered with it, but, if you can take the time to do the steps above, you will have a cleaner, faster, better, smoother running computer.
Comment if this helped you!
Paste your HJT logs if you need assistance.

18Sep/0949

Dreamweaver error: xml parsing fatal error: Invalid document structure

If you get an error like this, chances are one of your layout files went corrupt.
I received an xml parsing fatal error: mentioning that my workspace file Designer.xml could not be read.
If you get this error too, no worries, fixing it is simple.
Go to C:/. Click Tools>Folder Options. Click the View Tab. Click 'Show hidden files and folders'.

Navigate to C:/Documents and Settings/username/Application Data/Adobe/Dreamweaver/en_us/Configuration/Workspace. Make a new folder and move all files in that directory into this new folder. Close Dreamweaver and restart it. You should have no more problems with Dreamweaver (this may also work with Flash) and it should load.

Comment if this helped :)

Filed under: General 49 Comments
15Sep/094

Easy, Simple Paging Using PHP

Easy & Simple Paging using PHP. Here is the result: (DB has 8records, Rows per page is set to 5, and we're on page 2)
advertisers

Paging usually takes a while but here we will do it quickly and cleanly.

Your page will be named page.php. And when we want to switch pages we will make it page.php?pg=2.
Im sure you've seen this before. Anyways lets dive in.

I use shorthand to clean stuff up, but basically shorthand is

$returnvalue=(condition ? "true" : "false");
Example:

$is_loggedin=(isset($_SESSION["loggedin"]) ? 1 : 0);
After this statement, if the session variable is set, $is_loggedin will equal 1, else it will equal 0.

At the top of your PHP page type the following:

<?php
/*paging*/
Line 1: $pg=(isset($_GET["pg"]) && is_numeric($_GET["pg"]) && $_GET["pg"]>0 ? $_GET["pg"] : 1);
Line 2: $rowsperpage=10;
Line 3: $offset=($pg>1 ? ($pg-1)*$rowsperpage : 0 );
Line 4: $limitstr=" LIMIT $offset, $rowsperpage";
?>

Explanation:
First of all Limit is : LIMIT $startrowid, $number of entries to return
So LIMIT 55, 5 means start at row 55 and return 5 rows (55, 56, 57, 58, 59)

Line 1: If in the query string the pg is set e.g page.php?pg=4, and it is numeric, and greater than 0 we will assign the value of $_GET["pg"] to our $pg variable. If it is not set, or it is not numeric, or zero or less, we set the $pg variable to 1.
Line 2: We set our rows per page
Line 3: If the page is greater than 1, we set the offset to ($pg-1)*rowsperpage. If the page is 1 or less, we set offset to 0.
Line 4: We create the limit string for the sql statement. This will output something like LIMIT x, y.
(rowsperpage set to 10)

In this case page.php?pg=1
$pg = 1;
$offset = 0;
$rowsperpage=10;
$limitstr="LIMIT 0, 10"; //this string will pull 10 rows starting from row 0 (the first row) (rows 0-9)

In this case page.php?pg=3
$pg=3;
$offset= (3-1) * 10; //offset calculates to 20
$limitstr="LIMIT 20, 10"; //this string will pull 10 rows starting from and including row 20 (rows 20-29)

Ok. Now that we got that out of the way.

We will use a simple query, then we will attach our new limit string (looking at case 2 above)
$sql="SELECT * FROM MEMBERS $limitstr"; //sql = "SELECT * FROM MEMBERS LIMIT 20,10";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res)){

//processing if you need to
}

We also need to know the total count for this table
$sql="SELECT COUNT(memberid) FROM MEMBERS";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
$total = $row[0];

Now we know the total count.

So we need to calculate the number of pages. That is done by this formula:
($total/$rowsperpage);
Now in the case of 26 members and 5 rows per page. Using this formula 26/5 = 5.2pages, so we need to round up!

$maxpage=ceil($total/$rowsperpage); //max page is now 6.

Ok, we got everything set up :) Just need to print out our paging!
Wherever you want your paging setup add this:

<?php
print '<div class="paging"><ul>';
for($i=1; $i<=$maxpage; $i++){
  if($pg==$i)
     print '<li><span>'.$i.'</span></li>';
  else
     print '<li><a href="?pg='.$i.'">'.$i.'</a></li>';
}
print "</ul></div>";
?>

Then we can do some nice styling (Mess around with margins to setup spacing)
CSS
div.paging {text-align: center; margin-top: 5px;}
div.paging span{font-weight: bold;}
div.paging ul{overflow: hidden;}
div.paging ul li{width: 10px; float: left; margin: 0px 10px 5px 0px;}

This will page across until it hits the edge of the div, then it will move to the next line.

ENJOY and comment ! :)

2Sep/090

Recursing through a directory/filesystem using C#

This will teach you how to recurse through a directory/filesystem using C#..
The problem comes from not knowing how many folders/files exist.
One folder can have many folders inside it, those folders can each have many folders inside it.

I will show you how to recurse through the filesystem and explain it so that you UNDERSTAND it. This isnt for copy-paste.

We will start with a C# console application and pick a path, we'll use C: for this.
First of all, we're going to need the IO namespace. The IO namespace has access to File and Directory methods.

At the top add these lines:

using System; //Just so we can use the shortcut Console instead of System.Console
using System.IO; //Gives us access to file, directory objects

Now, in our "main" method, we are going to write the following:

string path="C:/"; //set the root path we want to recurse through.

//check if the directory exists
if(Directory.Exists(path)){
        DirectoryInfo di=new DirectoryInfo(path);
        //based on a path, this object will give you directory information about that directory
        printDirectories(di);
        //this method will actually go through our directories and print out information
}else{
        Console.WriteLine("Directory does not exist. Press Enter to exit");
        Console.ReadLine(); //when you hit return the program will terminate.
}


Now we will write the print directories method. It takes a DirectoryInfo object as a parameter and will use that to recurse through the file system.

//declared as static because were a console app, this can be private in your application if it a utility method.
2 Important methods we're going to be looking at are in the DirectoryInfo object. They are

public FileInfo[] directoryInfoObject.GetFiles() //returns an array of FileInfo objects
public DirectoryInfo[] directoryInfoObject.GetDirectories() //returns an array of DirectoryInfo objects

static void printDirectories(DirectoryInfo di){
       foreach(FileInfo fi in di.GetFiles()){
              //we are going to run code for each file
              Console.WriteLine(fi.FullName); //this prints out the full file name including the path
       }

      //now that we process this directory for files, we do the same for every subdirectory in this directory
      foreach(DirectoryInfo subDir in di.GetDirectories()){
             //we are going to call the printDirectories method, with the subdirectory as the root.
            //its files will be processed, then its subdirectories will be checked
            //this happens foreach Directory in the current directory
            printDirectories(subDir); //recurse
      }
}

Thats simple recursion. The most common use of this is for populating a treeview and another use that comes to mind is file searching. Keep an eye out for the next tutorial: Populating a Treeview from a file system!

21Jun/0911

Adding/Insert Line Breaks into a Textarea

Seems like a simple enough problem to solve...just use \n or a br tag
right? ...wrong.
This markup <textarea>Test<br/>Newline</textarea> produces:

And the markup <textarea>Test\nNewline</textarea> produces:

The trick to inserting a new line is to use the character for a carriage return. I stumbled upon this when I ran into this problem. I opened a new notepad file and made a simple textarea. When typing in it, I noticed that when I press enter it goes to a new line (obviously), so I figured why not try to put a carriage return into the textarea. The carriage return representation is &#13; .

So the markup <textarea>Test&#13;Newline</textarea> produces:

And there you have it, simple problem to which the answer may take 30+ minutes to find.
Hopefully I save you that 30 mins :)
Comment, Enjoy :)

17Jun/090

Using javascript to opening a new window W3C Validation target="_blank" alternative

<a href="http://www.google.com" target="_blank">Google!</a>
Perfect way to open a new window right? WRANG! (End of the world flash reference ...look it up)

Your webpages may not pass W3C validation because your still using target="_blank".
This article will show you how to use javascript or jquery to open a new window, and have your webpages pass W3C Strict Validation.

Anyyyyyyyyyyyways, using the target attribute of the a tag was a perfectly valid way of opening a link in a new window. However, this currently does not pass certain XHTML Validations. I assume you found this blog post because you need to validate and target="_blank" isn't passing.

This solution will open your link in a new window.
<a href="http://www.google.com" onclick="window.open(this.href);return false;">Google New Window!</a>

What this does is use window.open, and passes the links href attribute as the url.
The reason for "return false", is so that the base web page does not open the link as well.

Another cool alternative is to use JQuery...ya I know this is javascript but if you have jquery already loaded you can add this to your document.ready function.

$(document).ready(function(){
$("a.newWin").click(function(){
window.open($(this).attr("href"));
return false;
});
});

<a href="http://www.google.com" class="newWin">Google</a>

Any link with the class newWin will now open in a new window.

Both these methods validate to XHTML Strict and are easy to implement.

Enjoy.

9Jun/090

CSS Cross Browser Compatibility – Conditional Comments/CSS Hacks

CSS Hacks/Conditional Comments

This is going to be a short/quick article. Straight to the point.
The lack of Cross browser support for CSS2 is horrible. CSS3 will soon be standard and implemented across many newer browsers, but until then here are a few suggestions on targeting different browsers.

Using a global reset.css is important, this resets a lot of the properties which may be different across browsers and gives you a good baseline starting point. A global reset can iron out many browser inconsistencies.

CSS Reset.css

This was taken from http://stylizedweb.com/2008/02/14/10-best-css-hacks/

html, body, div, span, applet, object,
iframe, h1, h2, h3, h4, h5, h6, p, blockquote,
pre, a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp, small,
strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, table, caption, tbody, tfoot,
thead, tr, th, td {
border:0pt none;
font-family:inherit;
font-size:100%;
font-style:inherit;
font-weight:inherit;
margin:0pt;
outline-color:invert;
outline-style:none;
outline-width:0pt;
padding:0pt;
vertical-align:baseline;
}
table {
border-collapse:separate;
border-spacing:0pt;
}
caption, th, td {
font-weight:normal;
text-align:left;
}
blockquote:before, blockquote:after, q:before, q:after {
content:"";
}
blockquote, q {
quotes:"" "";
}
strong {
font-weight:bold;
}
em {
font-style:italic;
}
* {
margin:0pt;
padding:0pt;
}

Conditional Comments

Conditional comments
Implemented by IE to fix their retarded browsers, conditional comments can help you target different versions of IE.

<!--[if IE 6]>
Any instructions in this comment will be parsed by IE 6.
<![endif]-->

<!--[if IE 7]>
Any instructions in this comment will be parsed by IE 7.
<![endif]-->

<!--[if lte IE 7]>
Any instructions in browsers less than or equal to IE7 will
parse these comments.
<![endif]-->

Example of using conditional comments:
<!--[if IE 7]>
<link href="styles/ie7styles.css" rel="stylesheet" type="text/css" />
<![endif]-->

CSS Hacks

There are many CSS hacks. However, these are the couple I find most useful.

Star-property Hack

*property: value;

Not sure on the name but I call this the star-property hack. This hack allows you to target IE7 and below.

Underscore-property Hack

_property: value;

This targets IE6 and below. Any styles will be applied to ie 6 and below.

!important Targetting

The !important at the end of a style, tells browsers that this property should override any other declarations of that property regardless of position. For example in this case:
width: 10px !important;
width: 80px;

Even though the 80px declaration comes second, Firefox 3 and IE7/8 will render this style as 10pixels. IE6 does not recognize the !important declaration and will apply an 80pixel width.

I prefer this method when I need to target IE7 and FF with one rule, and IE6 with the other. This is a valid method of feeding one rule to ie7/ff and another for ie6.

CSS Examples
div.test{
margin-top: 10px; //firefox
*margin-top: 15px; //ie7
}

div.test{
margin-top: 10px; //firefox
*margin-top: 5px; //ie7
_margin-top: 2px; //ie6
}

div.test{
margin-top: 10px !important; //ff and ie7
mragin-top: 2px; //ie6
}

NOTE: The star property hack and the underscore property hack are NOT valid css, but sometimes you need to get a little dirty to fix IE7 and IE6 issues. With the release of IE8, hopefully the inconsistencies of cross browser css will finally be ironed out, however people will still insist on using IE7...so knowing how to support it is important.

Hope you enjoyed.

7Jun/090

Wallpaper/Image Gallery Tutorial using HTML/CSS

One of the most important things ive learned while learning about html and css is the power of the unordered list. I was making a wallpaper gallery for my Death Note website and asked on Web Design Forums.net the best way to go about this. The answer I got changed the way I design and the way I layout my sites.

I'd like to thank Shadowfiend for showing me this technique. Learning it has changed the way i design. Check out his blog here: Shadowfiend | http://shadowfiend.posterous.com/

Unordered lists are a familiar topic of study in beginner html courses, however the markup often looks like

<h1>Fruits</h1>
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Oranges</li>
</ul>

However, this is not the only way to use them, nor is it the most powerful.
The unordered list is often used many times with Menus (both vertical and horizontal) as well as with image galleries.
I'm not going to show you the menu, because the wallpaper effect is harder, and if you learn it, you'll easily be able to make a menu.
For this, we are going to use any image. Find one on Google Images Search.
Alright now that we have our wallpaper, we will use a layout we created in my last post. If you want, you can go there and download layoutfooter.html, if you are comfortable with css you can just continue reading.

Now, between <div id="content"> we will add an unordered list as so...

<ul class="gallery">
<li>Image1</li>
<li>Image2</li>
<li>Image3</li>
</ul>

For now, dont use actual images, well use those after.
The first thing you may notice previewing these in your browser is that there are bullets. This is the default behavior of the unordered list.
We will take these off.

Between your <style> tags, add these rules:
ul.gallery{
width: 100%; /*this can be changed, its at 80% for better visualization at the moment*/
list-style-type: none;
overflow: hidden; /*helps fix certain issues*/
border: 1px solid blue; /*this helps us visualize while were laying out, this will be removed in the final product*/
}

Alright, now that we have styled our outer container, lets style our list items.

ul.gallery li{
border: 1px solid red; /*visualization*/
float: left; /* what this does is place each li out of normal flow, and as far left as it can. Since each li is floated left they will sit next to each other*/
width: 30%; /*set a width*/
height: 190px; /*set the row-height(actually the li height, but it simulates row height)*/
}

Heres what you should have at the moment (your list items will be higher)

Wallpaper CSS Layout Tutorial 1

Wallpaper CSS Layout Tutorial 1

The list items are right next to each other. We can add a margin-left on the li items to solve this. Lets do that now.

ul.gallery li{
/* keep all existing rules */
margin-left: 2%;
}

You can work in px, or %. If your working in a fixed width layout, it does not really matter. If you refresh and take a look, you'll notice were looking a lot better. Now, lets add our actual images.

Your unordered list will now look like this:

<ul class="gallery">
<li><img src="wall.jpg" alt="Wallpaper1"/></li>
<li><img src="wall.jpg" alt="Wallpaper2"/></li>
<li><img src="wall.jpg" alt="Wallpaper3"/></li>
</ul>

Dont worry about the images sticking out...we will fix this.
Ideally, you should have a full size image, and a thumbnail image. This allows for faster load times. By reducing the size of a pictures height and width in css, you do NOT reduce the load time, the full image is loaded, and then scaled, so best practice = have 2 sizes!

now we will add rules to style our image

ul.gallery li img{
display: block;
margin: 0 auto;
width: 180px;
height: 150px;
border: 1px solid #ccc; /*border effect*/
padding: 2px 8px 10px 8px; /*padding +border gives a nice effect*/
margin-bottom: 2px; /*push the next item below me down 2 pixels*/
}

You'll notice theres a little space beneath the image, dont get rid of it! We have plans for this :D . Also, a lot of the above was included because it looked nice. All of the above are optional, the image would just be aligned left with no padding/border.

Modify your markup so it looks like this

<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 1</p></li> <li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 2</p></li> <li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 3</p></li>

We will now style the p tag. Remember the margin-bottom on the img ? This will push this down 2pixels, so we have space :)

ul.gallery li p{
margin: 0 auto; /* center the box*/
text-align: center; /* center the text within the box*/
width: 192px; /*set a width for our label*/
border: 1px solid #ccc;
}

Copy and paste the li's. So that you double/triple them, like so.

<ul class="gallery">
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 1</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 2</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 3</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 1</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 2</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 3</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 1</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 2</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 3</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 1</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 2</p></li>
<li><img src="wall.jpg" alt="Wallpaper 1"/><p>Wallpaper 3</p></li>
</ul>

Here you'll notice that the spacing between rows is none.
We add this rule to ul.gallery li{ margin-bottom: 5px;}

Now, take out the borders from ul.gallery and ul.gallery li And were done :)

here is the full css
-------------------------------------------------------------------------
ul.gallery{
width: 100%; /*this can be changed*/
list-style-type: none;
overflow: hidden; /*helps fix certain issues*/
}

ul.gallery li{
width: 30%;
height: 190px; /*set the row-height(actually the li height, but it simulates row height)*/
margin-left: 2%;
margin-bottom: 5px;
float: left;
}

ul.gallery li img{
display: block;
margin: 0 auto;
width: 180px;
height: 150px;
border: 1px solid #ccc; /*border effect*/
padding: 2px 8px 10px 8px; /*padding +border gives a nice effect*/
margin-bottom: 2px; /*push the next item below me down 2 pixels*/
}

ul.gallery li p{
border: 1px solid #ccc;
width: 192px; /*set a width for our label*/
text-align: center;
margin: 0 auto;
}

AND the final product:

CSS Wallpaper Tutorial

CSS Wallpaper Tutorial

Hope you enjoyed.
Feel free to comment/make requests.

Download: wallpaper_tut.html

Right click and click Save Link As..to Download

14May/090

USB Backup Utility with Batches

After my USB got FRIED behind the damn photocopier in the library a couple years ago, I had to re-do my whole Java Assignment AGAIN. I decided to make a little backup utility that would make it a little easier to back up my usb. It will only work if the pen drive is a fixed letter, but its always E: on my computer so thats fine by me. It consists on 2 files placed on the usb, a backup.bat that does the backing up and an autorun.inf which puts the Backup option into the autorun screen. When i plug my USB pen drive, the autorun gives me the option to backup, making an exact copy of my usb at c:/usb

Open notepad and paste this text in.

@echo off
echo USB BACKUP UTILITY V1.0
echo CREATED BY SCOTT
echo ----------------------------------------------------------
echo Starting Backup:
cd \
c:

if exist c:\usb goto exists
mkdir "USB"
goto copy

:exists
rmdir "USB" /s /q
mkdir "USB"

:copy
echo Date>C:\usb\backup.txt
date /t>>C:\usb\backup.txt
echo.>>C:\usb\backup.txt
echo Time>>C:\usb\backup.txt
time /t>>C:\usb\backup.txt
echo ------------------------------------------->>C:\usb\backup.txt

cd \
xcopy E:\* "C:\USB" /y /e /r /v>>C:\usb\backup.txt
echo Backup Complete!
echo.
echo Backup of entire USB at C:/USB
echo Log file placed at C:/USB/backup.txt
echo ----------------------------------------------------------
Pause

In the line xcopy E:\* "C:\USB" /y /e /r /v>>C:\usb\backup.txt, replace E: in this line with your actual drive letter.
Save this file as backup.bat making sure that "All Files" is selected from the files drop down box.


Next repeat the same steps, saving this text as autorun.inf

[autorun]
action=Backup
open=backup.bat
label=MyUsbName
includeRuntimeComponents=True

Save both these files on the root of your USB.
The next time you plug your usb in, you will see the autorun option "backup".
By clicking this and hitting ok, a full usb backup will be performed and put in C:/USB