My application has an uninstall script which is written in VBScript. This script deletes all the registries and is supposed to uninstall sql server as well as delete the database that has been created during install. I want to take a backup of the database instead of deleting it.
So I have written a function to rename the mdf and ldf files with VBS, but I get a permission denied error for this method.
Dim file
DBfile = "C:\Program Files\Microsoft SQL
Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\DB.mdf"
Sub backupDBFiles(file)
Dim filesys
Set filesys = WScript.CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(file) Then
filesys.MoveFile file, file & "backup"
End If
End Sub
backupDBFiles(DBfile)
The backupDBFiles
method works for any other file, so I think that this method should ideally rename the mdf file, but gives me a permission denied error. Is there a way to fix this error?