Serv-U Helm3 Quota Interface

'Serv-u Account Management
ver="V2.0"
'servudiskq.vbs

'Server Settings
'Helm SQL/MSDE Server Location
HelmDB="vicky\helm"

'Serv-U Domain Instance, this is located in the registry
SUDomain=1

'ServuDaemon File Location
ServuDaemon="C:\Program Files\Serv-U\ServUDaemon.ini"

'Operations: True is for enabled, Fales is for disabled.
'This will enabled writing the quota to the serv-u registry
SetQuota=True
'This will enabled or disabled the account based on the user account status
SetStatus=True

WScript.Echo "Serv-u Helm Qouta " & ver

'Check if Serv-U ini Exists.
Set filesys = CreateObject("Scripting.FileSystemObject")
If NOT filesys.Fileexists(ServUDaemon) Then
 wscript.echo "ERROR... ServuDaemon.ini does not exist"
 Set filesys = nothing
 wscript.quit(5)
end if

'Check for Servu-Domain In Registry
Set objShell = WScript.CreateObject("WScript.Shell")
SUDomainChk=""
On Error Resume Next
SUDomainChk=objShell.RegRead("HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\DomainList\" & SUDomain)
On Error Goto 0
If SUDomainChk = "" Then
 wscript.echo "ERROR... Serv-U Domain Not Found"
 Set objshell = nothing
 wscript.quit(5)
end if

Set rsOBJ = CreateObject ("ADODB.Recordset")
strConnect = "Driver={SQL Server}; Server=" & HelmDB & "; Database=helmdb;"

'Open Helm
WScript.Echo "Connecting to Helm Database..."
rsOBJ.Open "Select FTPAccount.FTPUserName, COALESCE(HostDomain.CurrentDiskspaceUsage,0) AS CurrentDiskSpaceUsage, SUM(Limit.LimitValue) AS DSTotal, Account.AccountStatus From FTPAccount,HostDomain,Package, Limit, Account WHERE FTPAccount.DomainId=HostDomain.DomainId  AND HostDomain.PackageId = Package.PackageId  AND Limit.LimitPropertyId=3 AND Package.AccountNumber = Account.AccountNumber AND(Package.PackageTypeId=Limit.ItemId OR HostDomain.PackageId=Limit.ItemId) GROUP BY FTPAccount.FTPUserName, HostDomain.CurrentDiskspaceUsage, Account.AccountStatus", strConnect
Do While Not rsOBJ.EOF
 CurrentDiskSpace_Bytes=rsObj("CurrentDiskspaceUsage")
 
 'Error Checking
 WScript.Echo "Found User " & rsObj("FTPUserName") & " Used/Total " & FormatNumber(cstr(rsObj("CurrentDiskspaceUsage"))/1024) & "MB/" & FormatNumber(cstr(rsObj("DSTotal"))) & "MB"
 
 If rsObj("AccountStatus") = 0 Then
  wscript.echo vbTab & "Account is Enabled"
  If SetStatus Then
   objShell.RegWrite "HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\" & SUDomain & "\UserSettings\" & rsObj("FTPUserName") & "\Enable", "1", "REG_SZ"
   wscript.echo vbTab & "Writing Account Status"
  else
   wscript.echo vbTab & "Skipping Status..."
  end if
 else 
  wscript.echo vbTab & "Account is Disabled"
  If SetStatus then
   objShell.RegWrite "HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\" & SUDomain & "\UserSettings\" & rsObj("FTPUserName") & "\Enable", "0", "REG_SZ"
   wscript.echo vbTab & "Writing Account Status, Account Disabled"
  else
   wscript.echo vbTab & "Skipping Status..."
  end if
 end if    

 If SetQuota Then
  'Update Serv-U Registry
  SUQuota="1|" & cstr(rsObj("DSTotal"))*1048576 & "|" & cstr(rsObj("CurrentDiskspaceUsage"))*1024
  objShell.RegWrite "HKLM\SOFTWARE\Cat Soft\Serv-U\Domains\" & SUDomain & "\UserSettings\" & rsObj("FTPUserName") & "\DiskQuota", SUQuota, "REG_SZ"
  WScript.Echo vbTab & "Writing Serv-u Qouta for " & rsObj("FTPUserName")
 else
  Wscript.Echo vbTab & "Skipping Quota..."
 end if
 rsOBJ.MoveNext
loop

objShell.run "cmd /c echo ReloadSettings=True >> """ & ServuDaemon & """",0
Wscript.Echo "Forcing Serv-U to reload settings."
Wscript.echo "Done."

'Close Us Down
rsOBJ.Close
set rsObj = nothing
Set filesys = nothing
set objshell = nothing
WScript.quit

This is an OLD vb script that I wrote for HELM3 to read the FTP users and their quota from a SQL database and writes the data to the registry to enforce the quota from the FTP Server.