palpatin
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору два скрипта для проверки свежести баз симантека и прав текущего пользователя на запись в системные папки и отправки их (пропустил это). из за UAC не работает. как исправить? запуск с админ правами не подойдет, т.к. теряется смысл второго скрипта Код: script_version=1.2 Set WshShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set WshNetwork = CreateObject("WScript.Network") symantec_path="c:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat" sComputer = LCase(WshNetwork.ComputerName) + "." + LCase(WshNetwork.UserDomain) + ".net" sDomain = LCase(WshNetwork.UserDomain) + ".net" If objFSO.FileExists(symantec_path) Then Set objFile = objFSO.GetFile(symantec_path) Set objDatFile = objFSO.OpenTextFile(objFile, 1) Do Until objDatFile.AtEndOfStream strLine = objDatFile.Readline intCurDefs = InStr(strLine , "CurDefs") If intCurDefs > 0 Then strCurDefs = strLine strDateDefs = Mid(strCurDefs, 9, 8) dtYear = Left(strDateDefs, 4) dtMonth = Mid(strDateDefs, 5, 2) dtDay = Right(strDateDefs, 2) DateVirDefs = dtMonth & "/" & dtDay & "/" & dtYear dtDefDate = CDate(DatevirDefs) strRevNumber = Right(strCurDefs, 3) If (date - dtDefDate) <= 7 Then trap_type = "OK" trap_desc = "<b>" & sComputer & ":</b> Virus Definition up to date <br><b> def date:</b> " & dtDefDate & " <br><b>ver:</b> " & strRevNumber Else trap_type = "WARNING" trap_desc = "<b>" & sComputer & ":</b> Virus Definition older then 7 day <br><b>def date:</b> " & dtDefDate & "<br><b> ver:</b> " & strRevNumber End If End If Loop objDatFile.Close Else trap_type = "CRITICAL" trap_desc = "<b>" & sComputer & ":</b> Virus Definition file not found!" End If ... end if | Код: 'Option Explicit script_version=1.1 Dim WshShell, WshSysEnv, checking_dirs(3), cdir Dim trap_type, trap_desc Dim sComputer, sUser Set WshNetwork = CreateObject("WScript.Network") Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("process") sComputer = LCase(WshNetwork.ComputerName) + "." + LCase(WshNetwork.UserDomain) + ".net" sDomain = LCase(WshNetwork.UserDomain) + ".net" sUser = LCase(WshNetwork.UserName) & "@" & sDomain trap_type="OK" checking_dirs(0) = WshSysEnv("SYSTEMDRIVE") checking_dirs(1)= WshSysEnv("WINDIR") checking_dirs(2)= checking_dirs(1) & "\system32" checking_dirs(3)= WshSysEnv("ALLUSERSPROFILE") for each cdir in checking_dirs if IsPathWriteable(cdir) then trap_type="CRITICAL" writ_dirs= writ_dirs & cdir & "," else unwrit_dirs= unwrit_dirs & cdir & "," end if next if len(writ_dirs)>1 then writ_dirs=left(writ_dirs,len(writ_dirs)-1) & " is writeable" if len(unwrit_dirs)>1 then unwrit_dirs=left(unwrit_dirs,len(unwrit_dirs)-1) & " is read-only" trap_desc = replace("<b>" & sComputer & ": </b> " & writ_dirs & unwrit_dirs & " for user " & sUser,"\","\\\") .... end if Function IsPathWriteable(Path)' As Boolean Dim fso 'As Scripting.FileSystemObject Dim Temp_Path 'As String if right(path,1)="\" then path=left(path,len(path)-1) Set fso = CreateObject("Scripting.FileSystemObject") Temp_Path = Path & "\" & fso.GetTempName() On Error Resume Next fso.CreateTextFile Temp_Path IsPathWriteable = Err.Number = 0 fso.DeleteFile Temp_Path On Error Goto 0 End Functionf | |