IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Ménage sur disque C


Sujet :

VBScript

  1. #1
    Nouveau candidat au Club
    Femme Profil pro
    Analyste d'exploitation
    Inscrit en
    Décembre 2011
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Décembre 2011
    Messages : 1
    Par défaut Ménage sur disque C
    Bonjour,
    J'aimerais écrire un script avec une fonction qui regroupe tous les delete des fichiers sur C: pour faire du ménage, voici mon script :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    '--------------------------------------------------------------------------
    ' This script deletes the file to free up on disks
    '
    ' Commands are in files : CmdLine.bat
    '--------------------------------------------------------------------------
    '
    ' VARIABLES
    '
    '--------------------------------------------------------------------------
    dim CmdLine, folder
    dim WINDIR
     
    Set WshShell = WScript.CreateObject("WScript.Shell" )
    WINDIR = WshShell.ExpandEnvironmentStrings("%WinDir%" )
     
    Set fso = CreateObject("Scripting.FileSystemObject" )
    Set MyFile = fso.CreateTextFile("c:\AdminServeurs\CmdLine.bat" ,True)
     
    '--------------------------------------------------------------------------
    '
    ' Delete of tempory file 
    '
    '--------------------------------------------------------------------------
    folder = WINDIR & "\temp"
     
    if fso.FolderExists(folder) then
        CmdLine = "del " & folder & "\*.* /Q /F "
        MyFile.WriteLine(CmdLine)
    end If
    '--------------------------------------------------------------------------
    folder = WINDIR & "\system32\config\%USER%\local settings\temp"
     
    if fso.FolderExists(folder) then
        CmdLine = "del " & folder & "\*.* /Q /F /S"
        MyFile.WriteLine(CmdLine)
    end If
    '--------------------------------------------------------------------------
    folder = "c:\Temp"
     
    if fso.FolderExists(folder) then
        CmdLine = "del " & folder & "\*.* /Q /F /S"
        MyFile.WriteLine(CmdLine)
    end If
    '--------------------------------------------------------------------------
    '
    ' Empty the directory RECYCLER
    '
    '--------------------------------------------------------------------------
    folder = "c:\RECYCLER"
     
    if fso.FolderExists(folder) then
        CmdLine = "del " & folder & "\*.* /Q /F /S /A"
        MyFile.WriteLine(CmdLine)
    end If
    '--------------------------------------------------------------------------
    '
    ' Delete the directory ServicePackFiles
    '
    '--------------------------------------------------------------------------
    folder = WINDIR & "\ServicePackFiles"
     
    if fso.FolderExists(folder) then
        CmdLine = "Rmdir " & folder
        MyFile.WriteLine(CmdLine)
    end If    
    '--------------------------------------------------------------------------
    '
    ' Empty the directory \software distribution\download
    '
    '--------------------------------------------------------------------------
    folder =  WINDIR & "\softwaredistribution\download"
     
    if fso.FolderExists(folder) then
        CmdLine = "del " & folder & "\*.* /Q /F /A"    
        MyFile.WriteLine(CmdLine)
    end If
     
    '-------------------------------------------------------------------------
    ' END of the SCRIPT and RUN .bat 
    '-------------------------------------------------------------------------
    MyFile.Close
    Set MyFile = Nothing
    Set fso = Nothing
    Return = WshShell.Run ("c:\AdminServeurs\CmdLine.bat",10,TRUE)
    Je n'arrive pas à regrouper tout ces actions.

    Pouvez vous m'aider svp

  2. #2
    Expert confirmé
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 124
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 124
    Par défaut
    Salut

    Quelque chose comme çà
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    '--------------------------------------------------------------------------
    dim WshShell, fso
    dim WINDIR, MyFile, Retour
     
    '--------------------------------------------------------------------------
    Sub EcritLigne(Action, Dossier, Arguments)
    if fso.FolderExists(Dossier) then MyFile.WriteLine(Action & Dossier & Arguments)
    End Sub
    '-------------------------------------------------------------------------
     
    Set WshShell = WScript.CreateObject("WScript.Shell" )
    WINDIR = WshShell.ExpandEnvironmentStrings("%WinDir%" )
     
    Set fso = CreateObject("Scripting.FileSystemObject" )
    Set MyFile = fso.CreateTextFile("c:\AdminServeurs\CmdLine.bat" ,True)
     
    ' Delete of tempory file
    EcritLigne "del ", WINDIR & "\temp" , "\*.* /Q /F"
    EcritLigne "del ", WINDIR & "\system32\config\%USER%\local settings\temp" , "\*.* /Q /F /S"
    EcritLigne "del ", "c:\Temp" , "\*.* /Q /F /S"
    ' Empty the directory RECYCLER
    EcritLigne "del ", "c:\RECYCLER" , "\*.* /Q /F /S /A"
    ' Delete the directory ServicePackFiles
    EcritLigne "Rmdir " , WINDIR & "\ServicePackFiles" , ""
    ' Empty the directory \software distribution\download
    EcritLigne "del ", WINDIR & "\softwaredistribution\download" , "\*.* /Q /F /A"
     
    MyFile.Close
    Set MyFile = Nothing
    Set fso = Nothing
     
    Retour = WshShell.Run ("c:\AdminServeurs\CmdLine.bat",10,TRUE)
    :whistle:pourquoi pas, pour remercier, un :plusser: pour celui/ceux qui vous ont dépannés.
    saut de ligne
    OOOOOOOOO👉 → → Ma page perso sur DVP ← ← 👈

Discussions similaires

  1. [Espace perdue sur disque dur]
    Par Abdul dans le forum Windows XP
    Réponses: 19
    Dernier message: 26/06/2005, 14h50
  2. UT2004 sur disque Windows
    Par black is beautiful dans le forum Applications et environnements graphiques
    Réponses: 4
    Dernier message: 08/03/2005, 21h44
  3. Installation sur disques SCSI en RAID 5
    Par ALT dans le forum Debian
    Réponses: 4
    Dernier message: 24/09/2004, 11h17
  4. Réponses: 2
    Dernier message: 27/02/2004, 13h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo