Thursday, 18 August 2016

Scam Alert - SMS Lotto Gewinnspiel

There are a lot of scams around these days, most come in via e-mail but the following is one I received by SMS. Here it is together with an explanation:

+447484732319 Congratulations! You have won 2,000,000. WIN No:HNNSY-251-4577509. Email: Now Claim Your winnings.

It says I've won a lot of money and without thinking I wonder how I can get my hands on the cash! 

Don't click anything! 
It looks a bit fishy doesn't it!?! 

Look carefully at the above screen shot and you'll see:
  • The mobile number it came from is a UK number (+44)
  • The prize is in euros, not pounds
  • The email address is - the word "gewinnspiel" is German, I looked it up in Google Translator and it means "contest"
  • I didn't enter a lottery! 
  • I didn't enter a lottery where I gave my mobile number!
If you put the above observations together you can see there is no way this can be true. It is a scam! Why is it from a UK number but there's a German word in the e-mail address? Why am I being sent this, I didn't enter a lottery. If I have recently entered any lottery, did I give my mobile number, if not then how did they send this SMS to me? Wouldn't they send me an e-mail perhaps?

Think carefully when you receive e-mails or SMS text messages like this one. If the information is not consistent, if you didn't sign up for something or enter a competition, or if it's just too good to be true - it's very likely to be a scam! 
Delete such messages and stay safe!

For a very detailed look at a similar scam please see the following link:

The above page is on the AVAST website. AVAST are an established and well known anti-malware company.

Monday, 6 June 2016

RoboBackup7z - an AutoIt script to backup files using Robocopy and 7za

Previously I wrote an AutoIt script called RoboBackup. That script used Robocopy to automate backing up files into three (or more) folders. It cycled through those folders synchronising files each time.

In this article I am going to explain a slightly more advanced script that also backs up files but does so by using both the Robocopy command and also the 7-Zip 7za.exe command line program. I've called this backup script 'RoboBackup7z'.

The idea behind RoboBackup7z is that the latest backup is a synchronised folder managed by Robocopy. But previous Robocopy backups are archived in 7z files for safe-keeping. This means the latest data is easy to recover and the previous backups are still available but are smaller compressed files you could copy elsewhere - to DVD or cloud storage perhaps.

First let's have a look at how this script works and after how it is put together. I hope you'll find this interesting.

The idea is that you create a folder on a removable drive or USB flash drive and run the script from there. In the following screen shot you can see my example:

In the above example I have an external USB hard disk drive that is drive G: on my computer. I am backing up files from my D: drive (source) and so I've created a folder called "D" (I could've called it anything but this makes sense to me).

Inside the "D" folder I have the following files:

  • 7za.exe
  • RoboBackup7z.au3
  • RoboBackup7z.exe
  • RoboBackup7z.ini

Edit RoboBackup7z.ini

Add a folder to backup. This can also be a drive letter, in our example we'll use D:. This backs up all folders and files found on drive D:.

Double click RoboBackup7z.exe

The first time it runs the following will be created:

  • A folder called Backup where a copy of the folders and files will be made.
  • A log file named yyyymmdd_hhmmss_LOG.txt (the RoboCopy log showing what was backed up).

The second time it runs the following happens:

  • A folder called Archive is created
  • 7-Zip runs, it adds all the folders/files from the Backup folder to a 7z archive file in the Archive folder.
  • It names the 7z with the name of the last backup log file (it gets this from the ini).
  • It splits the 7z file into 300MB separate files.
  • The log file is moved to the Archive folder.
  • RoboCopy runs again, the Backup folder is updated with new files, a new log file appears in the script folder.

The third time it runs:

  • The same as the second time, a new 7z is created and stored in the Archive folder with the log file. RoboCopy runs again to update the Backup folder and create a new log file.

In the above example I have run the script more than twice. The Backup folder contains the files of the latest copy and the Archive folder contains the 7z files. The log is the latest log file.

Here's what it looks like inside the Archive folder:

In the above screen shot you can see the txt files are the logs. You can open these in Notepad. They are the original log files produced by Robocopy when it originally ran.

The other files are the 7z files. They are in 300 MB chunks. To view and extract files open the first one (001) with 7-Zip for Windows.

IMPORTANT: There is no control over how much disk space is used or how many backups can be made. You must manage the disk space yourself. Move files from the Archive folder to another location as needed.

Source Code
In the following screen shot you'll see the code as I see it when I writing it. On the left hand side you can see the line numbers. Below the image I'll explain line by line what the script does but first a few basics, here's how the colour coding works:

Green - comments, text to explain what the script is doing. Therefore lines 1 to 11 is just for information.
Black - variables, they also start with a dollar sign $
Blue - functions like IF.
Orange - operators like <>=
Red - text

--- Line 15
This defines the $ini variable that identifies the RoboBackup7z.ini file. It's a configuration file containing the drive/folder to backup and the name of the last log file.

--- Line 17 to 25
These are the variables and what their initial values are. This includes reading data from the ini file.

--- Line 27 to 39
First this checks if the 7za.exe exists. If it does not, it'll skip this part.
If 7za.exe does exist then it'll check for the destination folder (Backup), if this exists then it'll run the 7za program to archive the files from the destination (Backup) folder.

--- Line 32
This is the 7za line. It compresses the files from the Backup folder into one or more 7z compressed (zipped) files. The 7za.exe has a number of parameters:

-r = recurse, meaning to archive sub-folders/files

-v300m = this splits the 7z archive file into smaller files (volumes). In this case we're splitting to 300MB files. You can change this to any size that fits your needs. If you do not use this parameter then the archive will be one large 7z file. Such a file might be very big, depending on what files you have to backup, larger than 2GB, therefore it makes sense to split to smaller files to make them easier to copy. Many services do not support files larger than 2GB.

--- Line 36 and 37
These copy the log file to the Archive folder. This is so the log is stored along with the backup it was made from.

--- Line 42
Save the date (name of the log file) to the ini file. This so it can be used the next time the backup runs to identify the 'last' backup.

--- Line 45
Runs ROBOCOPY to synchronise files from the source to the backup (destination) folder.

--- Line 57
Open Notepad and display the log file. This will happen at the end and shows you what has happened during this backup. It's the usual output from Robocopy.

--- Line 59
Exit just closes the script. You don't really need this but usually put it just to show where it ends.

My RoboBackup7z Script Source Code for Copy/Paste
Here's the same script as shown above in the screen shot. But this time it's text so you can copy/paste it and use it. Feel free you change it :-)

#cs ----------------------------------------------------------------------------

RoboBackup using 7-Zip

 AutoIt Version:
 Author:         Michael Gerrard /

 Script Function:
 Create a backup using Robocopy and archives using 7-zip

#ce ----------------------------------------------------------------------------

; Set variables
$ini   = @ScriptDir & "\RoboBackup7z.ini"

$FolderToBackup = IniRead($ini, "Settings", "FolderToBackup", @MyDocumentsDir)
$source     = '"' & $FolderToBackup & '"'
$dest   = @ScriptDir & "\Backup"
$archive  = @ScriptDir & "\Archive"
$today   = @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC
$log      = @ScriptDir & "\" & $today & "_LOG.txt"
$7za   = @ScriptDir & "\7za.exe"
$last   = IniRead($ini, "Settings", "LastBackup", "00000000_000000")
$7zBackup  = $archive & "\" & $last

; Check if a backup was done before, if so, archive it to a 7z file
If FileExists($7za) Then
 If FileExists($dest) Then
  DirCreate($archive) ;make sure the archive folder exists

  RunWait(@ComSpec & " /c " & $7za & " a -r -v300m -w -y " & $7zBackup & " " & _
  $dest & "\*.*", @ScriptDir, @SW_MINIMIZE) ; add to 7z archive file

  ; Move the log to the archive folder
  FileCopy(@ScriptDir & "\" & $last & "_LOG.txt", $archive)
  FileDelete(@ScriptDir & "\" & $last & "_LOG.txt")

; Write today's date and time to the ini
IniWrite($ini, "Settings", "LastBackup", $today)

; Run RoboCopy
RunWait(@ComSpec & " /c ROBOCOPY " & $source & " " & $dest & _
" /MIR /R:2 /LOG:" & $log & " /TEE" & " /XF desktop.ini ", @ScriptDir, @SW_MINIMIZE)

; /MIR = mirror
; /R:2 = retry twice
; /LOG: = record to a log file
; /TEE = output to the screen too
; /XF desktop.ini = don't copy the desktop.ini file (avoids getting the My Documents folder name)

; Display the log file
If FileExists($log) Then
 Run("notepad " & $log)

Other required files
For the script to work you'll need Robocopy, this command is included with Windows as standard. Also you'll need the 7za.exe file, you can download it free of charge from
For more detailed information please see the following article:

It's amazing what you can do with free tools! AutoIt is of course the easiest way to make a script that's compact and simple. Just look at how few lines of code I used. Robocopy and 7za too, excellent. This script works very nicely and I've been using it for several months now. But it has some shortcomings. For instance, I have to manage the disk space myself. Also it only backs up from one location (drive or folder location and sub-folders). But this is fine, it means I have more work to do in the future!

The script here is just an example. I do not provide it with any guarantee. I'm not advocating this script be used for anything specific, this article is just to demonstrate what can be done. Use at your own risk! 



Robocopy at Wikipedia

Various articles about Robocopy
7za, the 7-zip command line program

If you are looking for some help with creating self-extracting archives, please see my previous articles specifically on this more advanced subject:
PART 1 -
PART 2 -

Wednesday, 27 April 2016

7-Zip 7za command line zip tool

7-zip is an alternative to the native Windows zip function, WinZip or similar program for compressing files. 7-zip is free of charge, reliable and supports many formats. I wrote an article about it back in 2010, here's the link:

7-zip is primarily a Windows application, with a graphical user interface. Normally that's fine and often it's enough to manage your compressed files. However, sometimes it would be nice to automate the compressing of files. Maybe you want to backup files by just double clicking a file? In this case you can use 7za.exe, a command line program.

This article is an introduction to the 7za.exe command line tool. We'll have a look at how to download it and as an example we'll see how we can use it to backup files to a removable drive.

Browse to
Download and install the 7-zip Windows program.

On the same web page, on the Downloads page look for '7z Library, SFXs for installers, Plugin for FAR Manager' - click to download the 7zXXX_extra.7z file.

7z is the native compressed format of 7-zip, you can open it using the 7-zip Windows program you just installed. Extract the files to a folder. In the folder you'll find a file called 7za.exe. You don't need all the other files, you can just copy this one 7za.exe file and use this for your command line projects.

Example: Simple Backup
In this example I have a local D: drive with a folder called 'source' where I have some important files I want to backup. I have a USB flash drive that is drive E.
  1. Insert a USB flash drive
  2. Copy the 7za.exe file to the USB flash drive (for example)
  3. Open a command window (press Win-R, type CMD and press Enter)
  4. At the command prompt change to the USB drive where you put the 7za.exe file (in our example I will type E: [Enter] because my USB drive is drive E)
7za u -r "backup" "d:\source\*.*"       [Enter]

Example: backing up files from the local D: drive to a file called "backup" on the E: (USB drive)

The above command will take all the files in D:\source, compress and copy those files to a called backup.7z on my USB flash drive (drive G: in my case). Later if I update files in D:\source I can use the same command to update the backup.7z file. 

Let's have a closer look at the commnad line parameters we used: 

This means to update, only those files that have changed will be added/updated in the 7z file. 

This means to be recursive, it will copy all files from the source folder and sub-folders. 

In our example this will create a compressed archive file. All the files from the source folder will go inside this one compressed file. By default 7za will use its native 7za format, which is recommended. 

The files to backup, combined with the -r parameter it means that any folders/files below this folder will also be included. 

Command File (batch file) 
To make your life easier you can put the command line into a file and save it with the 7za.exe file on your USB drive. Whenever you need to backup those files just double click the command file. 

Open Notepad and enter the following two lines: 
7za u -r "backup" "d:\source\*.*" 

Save the file as 7zaBackup.cmd 

At any time you can double click 7zaBackup.cmd to run your backup. 

At the command prompt you can type:
7za -h   [Enter] get a list of parameters. More help is available at

If you are looking for some help with creating self-extracting archives, please see my previous articles specifically on this more advanced subject: 

An alternative for backing up files using the command line is RoboCopy. Click the following link to find many articles about this powerful tool: