Option Explicit on error resume next if WScript.Arguments.Length = 0 then WScript.Echo "Скрипт создания резевной копии данных сервера безопасности Secret Net Studio" & VbCrLf & _ "Использование: CScript.exe " & WScript.ScriptName & " <путь к папке с резервной копией>" WScript.Quit(-1) end if Dim ISODate ISODate = FormatNumber(Year(Now),0,,,vbFalse) & "-" &_ Right("0" & FormatNumber(Month(Now),0), 2) & "-" &_ Right("0" & FormatNumber(Day(Now),0), 2) & "-" &_ Right("0" & FormatNumber(Hour(Now),0), 2) & "-" &_ Right("0" & FormatNumber(Minute(Now),0), 2) & "-" &_ Right("0" & FormatNumber(Second(Now),0), 2) dim objFSO, objShell Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("WScript.Shell") if not objFSO.FolderExists (WScript.Arguments(0)) then WScript.Echo "Ошибка: папка " & WScript.Arguments(0) & " не существует" Wscript.Quit(-1) end if dim BackupDir BackupDir = objFSO.BuildPath (WScript.Arguments(0), ISODate) const ServerDirKey = "HKLM\SOFTWARE\Security Code\Secret Net Studio\Server\Security Server\LacusServerInstallDir" dim ServerDir ServerDir = objShell.RegRead (ServerDirKey) if (err.number <> 0) or (Len(ServerDir) = 0) then WScript.Echo "Ошибка: ошибка чтения ключа реестра " & ServerDirKey Wscript.Quit(-1) end if dim ConfigFile ConfigFile = objFSO.BuildPath (ServerDir, "ServerConfig.xml") objFSO.CreateFolder (BackupDir) if err.number then WScript.Echo "Ошибка создания папки " & BackupDir & ", errcode = " & err.number Wscript.Quit(err.number) end if objFSO.CopyFile ConfigFile, BackupDir & "\" if err.number then WScript.Echo "Ошибка копирования файла " & ConfigFile & ", errcode = " & err.number Wscript.Quit(err.number) end if dim Command, ErrCode Command = "%systemroot%\system32\dsdbutil.exe " & _ """activate instance SecretNet"" ifm ""create full " & _ objFSO.BuildPath (BackupDir, "SecretNet") & """ quit quit" ErrCode = objShell.Run (Command, 1, true) if ErrCode then WScript.Echo "Ошибка выполнения " & Command & ", errcode = " & ErrCode Wscript.Quit(ErrCode) end if Command = "%systemroot%\system32\dsdbutil.exe " & _ """activate instance SecretNet-GC"" ifm ""create full " & _ objFSO.BuildPath (BackupDir, "SecretNet-GC") & """ quit quit" ErrCode = objShell.Run (Command, 1, true) if ErrCode then WScript.Echo "Ошибка выполнения " & Command & ", errcode = " & ErrCode Wscript.Quit(ErrCode) end if WScript.Echo "Резервная копия данных сервера безопасности успешна создана в папке " & BackupDir