загрузка...
Дата публикации: 03.06.2021 17:56:52 |
пример на VBS
๋Очистка кэша 1С
WScript.Sleep(5000)
ON ERROR RESUME NEXT
Dim FSO
Dim first
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set colEnvVars = WshShell.Environment("Process")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery( _
"S_elect * From Win32_Process " _
& "Where Name = '1cv8.exe'")
For Each objProcess In colProcesses
objProcess.Terminate
Next
WScript.Sleep(1000)
FolderName1 = "\appdata\Local\Temp\"
FolderName2 = "\appdata\Local\1C\1Cv82"
FolderName3 = "\appdata\Roaming\1C\1Cv82"
FolderName4 = "\appdata\Local\1C\1Cv8"
FolderName5 = "\appdata\Roaming\1C\1Cv8"
If FSO.FolderExists(colEnvVars("userprofile") & FolderName1) Then
first = 0
GoSubFolders colEnvVars("userprofile") & FolderName1
End If
If FSO.FolderExists(colEnvVars("userprofile") & FolderName2) Then
first = 1
GoSubFolders colEnvVars("userprofile") & FolderName2
End If
If FSO.FolderExists(colEnvVars("userprofile") & FolderName3) Then
first = 1
GoSubFolders colEnvVars("userprofile") & FolderName3
End If
If FSO.FolderExists(colEnvVars("userprofile") & FolderName4) Then
first = 1
GoSubFolders colEnvVars("userprofile") & FolderName4
End If
If FSO.FolderExists(colEnvVars("userprofile") & FolderName5) Then
first = 1
GoSubFolders colEnvVars("userprofile") & FolderName5
End If
Wscript.Echo "1C Cashe deleted."
Set WshShell = Nothing
Sub DelFile(sFILE)
On Error Resume Next
FSO.DeleteFile sFILE, True
If Err.Number <> 0 Then
Wscript.Echo "Error deleting file: " & sFILE
End If
End sub
Function GetFolder(sFOLDER)
On Error Resume Next
Set GetFolder = FSO.GetFolder(sFOLDER)
If Err.Number <> 0 Then
Wscript.Echo "Error connecting to folder:" & sFOLDER & VBlf & "[" & Err.Number & "]" & Err.Description
Wscript.Quit Err.Number
End If
End Function
Sub GoSubFolders (objDIR)
ProcessFilesInFolder objDIR
Set sFolder = GetFolder(objDIR)
For Each eFolder in sFolder.SubFolders
If Len(eFolder.Name)= 36 then
GoSubFolders eFolder
End If
Next
If Len(sFolder.Name)= 36 then
FSO.DeleteFolder sFolder, True
End If
End Sub
Sub ProcessFilesInFolder (objDIR)
Set sFolder = GetFolder(objDIR)
If first = 1 then
first = 0
else
For Each objFile in sFolder.Files
DelFile objFile
Next
End If
End Sub
Назад в раздел