New
#1
Problem with VBS Syntax
I have been experimenting with running Scheduled backups with Macrium Reflect using a generated VB Script which I have successfully modified. I now wish to enhance the VBS to perform the backups only if an external drive exists (i.e. it is switched on), and if there is sufficient space for the backup image. I give below some code which I have extracted from the Macrium Knowledgebase and modified prior to inserting it into the existing script which is working fine.
Option Explicit
Dim FSoObject
Set FSoObject=WScript.CreateObject("Scripting.FileSystemObject")
If FSoObject.DriveExists("D:") Then
wscript.echo "D drive exists"
If GetFreeSpaceGB("D:\OS Partn backups") < 50 Then
wscript.echo "D:\OS Partn backups Space is < 50GB"
wscript.echo "D:\OS Partn backups Free Space is " & GetFreeSpaceGB
wscript.echo GetFreeSpace
End If
Else wscript.echo "D drive does not exist"
End If
Function GetFreeSpaceGB(ByVal drvPath)
Dim objFSo, d
Set objFSo = CreateObject("Scripting.FileSystemObject")
Set d = objFSo.GetDrive(objFSo.GetDriveName (drvPath))
GetFreeSpaceGB = d.FreeSpace/ (1024 * 1024 * 1024)
End Function
The use of "echo" is only temporary until I get the script to work. At present it displays the "D drive exists" and "Space is < 50GB" messages but has a runtime error on the next statement with :- Wrong number of arguments or invalid property assignment 'GetFreeSpaceGB' Code 800A01C2. 'OS Partn backups' is the name of the target folder on the external D: drive.
I would appreciate any suggestions for making this code work.