Making a System Restore programmatically | VB.NET

System Restore is a component of Microsoft’s Windows Me, Windows XP, Windows Vista and Windows 7, but not Windows 2000 operating systems that allows for the rolling back of system files, registry keys, installed programs, etc., to a previous state in the event of system malfunction or failure.

System Restore backs up system files of certain extensions (.exe, .dll, etc.) and saves them for later recovery and use. It also backs up the registry and most drivers.

The following resources are backed up:

  • Registry.
  • Files in the Windows File Protection (Dllcache) folder.
  • Local user profile.
  • COM+ and WMI Databases.
  • IIS Metabase.
  • Specific file types monitored.

System restores are normally created when software is installed using the Windows Installer, when Windows update installs a new update and there are so many other conditions. Don’t you think it must be vital function clipped with your software? Well, I dare say it must be! So, get the source code from below, and just do it.

Please note that this source code has been provided for Visual Basic .NET, which natively works with Microsoft Visual Basic 2008 and 2010 (including express editions).

Public Shared Sub RestorePoint()

‘Pointing to system restore

Dim restPoint = GetObject(“winmgmts:\.rootdefault:Systemrestore”)

If restPoint IsNot Nothing Then

‘Checking if its created successfully or not ‘Name of restore

If restPoint.CreateRestorePoint(“System Restore Test”, 0, 100) = 0 Then


‘Error message in the case of failure

MsgBox(“Operation failed, but you can still continue!”, MsgBoxStyle.Exclamation, “Ooops!”)

End If

End If

End Sub

You must run this code in a seperate thread so that your software’s performance may not go negative. The tutorial for it goes here:

This article is available as PDF.

This article is also available as PDF. You can download it from here (mirror: passechambre)

                          Feel free to copy this post, but don’t forget to provide a link-back.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s