» »

[VBScript] Brisanje temp

[VBScript] Brisanje temp

Microsoft ::

Nekaj sem caral z VBScript, ce bo kdo rabil. Je se mogoce kak napakica vmesa, samo nekaj ze dela. Skripta rabi za zagon parameter, ki je crka pogona, kjer hocemo pobrisati temp. Recimo, primer ce imamo na c particiji: cscript Skripta.vbs c

Koda:
'Error
On Error Resume Next

'Dim
Dim rootDrive
Dim documentsAndSettings
Dim localSettings
Dim localTemp
documentsAndSettings = "\Documents and Settings"
localSettings = "\Local Settings\Temporary Internet Files"
localTemp = "\Local Settings\Temp"

'Get arguments
If Wscript.Arguments.Count = 1 Then
    rootDrive = Wscript.Arguments.Item(0) & ":"
Else
   Wscript.Echo "Usage: cscript Skripta.vbs C"
   Wscript.Quit
End If

'Get all user accounts
Set fso = CreateObject("Scripting.FileSystemObject")
Set documentsAndSettings = fso.GetFolder(rootDrive & documentsAndSettings)
Set accounts = documentsAndSettings.Subfolders
For Each account in accounts
    EnumAllSubs fso.GetFolder(account & localSettings)
    If Err.Number <> 0 Then
        Wscript.Echo account & localSettings
        Wscript.Echo "Error0: " & Err.Description & VbCrLf
        Err.Clear
    End If
    EnumAllSubs fso.GetFolder(account & localTemp)
    If Err.Number <> 0 Then
        Wscript.Echo account & localSettings
        Wscript.Echo "Error3: " & Err.Description & VbCrLf
        Err.Clear
    End If
Next

Sub EnumAllSubs(folder)
    On Error Resume Next
    For Each subfolder in folder.SubFolders
        For Each file In subfolder.Files
            If fso.FileExists(file.Path) Then
                fso.DeleteFile(file.Path)
            End If
            If Err.Number <> 0 Then
                Wscript.Echo "Error1: " & Err.Description
                Err.Clear
            Else
                Wscript.Echo "File " & file.Path & " deleted"
            End If
        Next
        EnumAllSubs subfolder
    Next
    If fso.FolderExistst(folder) Then
        fso.DeleteFolder(folder)
    End If
    If Err.Number <> 0 Then
        Wscript.Echo "Error2: " & Err.Description
        Err.Clear
    Else
        Wscript.Echo "Folder " & file.Path & " deleted"
    End If
End Sub


by Miha


p.s.: Zakaj mora bit vnos kode tako blesav?!;((
s8eqaWrumatu*h-+r5wre3$ev_pheNeyut#VUbraS@e2$u5ESwE67&uhukuCh3pr


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

vba array

Oddelek: Programiranje
12923 (616) Vazelin
»

[C] izris trikotnika v konzoli

Oddelek: Programiranje
134173 (2448) darkkk
»

[VB] brisanje polne mape

Oddelek: Programiranje
5780 (707) jishiri
»

Kako bi napisal .bat file, da bi ...

Oddelek: Programiranje
231896 (1342) AtaStrumf
»

vkljucevanje txt datoteke v ...

Oddelek: Programiranje
131581 (1357) webblod

Več podobnih tem