Backup KeePass

Its important to have a backup copy of your password vault. An easy and robust solution is to use the Windows Task Scheduler program to schedule a regular backup.

To start, create a folder to hold the script and the backup. For example C:\Temp\Backup\.

Next, create and test a command that copies your keepass file to the backup location EG: “XCOPY C:\Users\88776655\Downloads\Database.kdbx C:\Temp\Backup\ /Y” and save it in a text document within the backup folder. EG: “C:\Temp\Backup\BackupKeePass”.

Change the properties of the “Backup” folder so you can see the file extensions IE: BackupKeePass.txt” …

Then change the extension from txt to bat and test it works (right-click, open).

  • Start up the Task Scheduler by typing it into the Windows search bar.
  • Right-click on “Task Scheduler Library” and create a new folder “My Tasks”.
  • Right-click on “My Tasks” and choose “Create Task”. Give it a name like “Backup KeePass” and click the radio-button “Run whether a user is logged in or not”
  • On the Triggers tab, schedule it or set it to run every log on.
  • On the Actions tab create a new action to start a program and browse to the bat file.
  • On the Settings tab, select “Stop task if runs longer than 1 Hour”, and click OK.

To test make a change in KeePass and save it. The reboot , login and examine the date the backup was created.

Resolving UserID’s in Event Viewer.

I wanted to find out who made a change on a server – on a known day at a known time. Looking through event-viewer on the server all I could find was an irrelevent “TerminalServices-Printers” error. However within this error – by clicking the Details tab and expanding the ‘system’ paragraph I saw a USERID, which was a long string of numbers and dashes.

To resolve this userid I opened regedit and expanded HKEY_USERS. I located the userID in question and right-clicked it. Examininmg the ‘permissions’ configuration the username was listed.

Open SSMS as another user

I cobbled together this script which sits on my desktop called ‘ssms.vbs’. The disadvantage is you need to hard-code your password into the script and keep it upto date.

set WshShell = WScript.CreateObject("WScript.Shell")

'build runas command 
WshShell.run "runas /user:DOMAINUSERNAME %comspec%"
WScript.Sleep 100
WshShell.SendKeys "PASSWORD" 'send password
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500

'Open SSMS
WshShell.SendKeys Chr(34) + "C:Program FilesMicrosoft SQL Server100ToolsBinnVSShellCommon7IDEssms.exe" + Chr(34)
WshShell.SendKeys "{ENTER}"

'Close command prompt
WshShell.SendKeys "exit"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000

set wshshell = nothing