V.

Vista User Backup Script

For those of us who have to re-image computers on a regular basis for people, we know backing up files can sometimes be a slow and painful process. So I decided to make this simple backup script out of VB Script that makes the process a ton easier.

Basically what it does is scans through the folders in the current user directory (ie: you copy the script to C:\Users\Bob) and any directory that is not a junction it starts a Robocopy instance that recursively copies all the files in that folder to a backup folder specified at the beginning of the script. When you first run the script you’ll see probably 10 Robocopy windows to start and they’ll all eventually close once they’re done.

Download

Can it work with XP? Probably, since XP doesn’t have junction points then it would just copy all the folders anyway.

R.

Regex and Anchor tags

I had been looking on the Internet for a solution to a program I had be working on and sadly didn’t come up with one. I was trying to find a way to use regular expressions to find all the html anchor tags in a string along with matching a wild card URL (ie: secnem.com.*test.html). And after many hours of thrusting my head into my keyboard I came up with:

/<a [^><]*href=[\”\’][^\”\’><]*<rule>[^\”\’><]*[\”\’][^>]*>\s*.*\s*<\/a>/iU

You’d replace <rule> with what ever url rule you want, except for any wild cards in the url I needed to use [^\”\’><]* instead of just .* . This would prevent it from matching outside of the anchor. Bascially [^\”\’><]*  means: match any character except a double quote, single quote, greater than sign, or less than sign. All of which should not be in the href field to begin with.

If you wanted to see what the content of the anchor tag was or the matched href, simply put some brackets around like so:

/<a [^><]*href=[\”\’]([^\”\’><]*<rule>[^\”\’><]*)[\”\’][^>]*>(\s*.*\s*)<\/a>/iU

Hope this helps someone. You can of course adapt this to other html tags by replacing ‘a’ for ‘table’ or w/e. Same with the href. larsolavtorvik.com has a great resource for testing regex in real time and addedbytes.com has a great cheat sheet as well.