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 :

probleme variable chemin d'accès


Sujet :

VBScript

  1. #1
    Candidat au Club
    Homme Profil pro
    Collégien
    Inscrit en
    Février 2017
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Collégien

    Informations forums :
    Inscription : Février 2017
    Messages : 4
    Points : 3
    Points
    3
    Par défaut probleme variable chemin d'accès
    Bonjour , j'ai un soucis avec un script vbs qui me servira a sauvegarder mes archives.pst .
    Je compte déployer ce script sur de nombreux postes et j'ai un problème avec une variable du chemin d'accès de la source qui doit être modifié pour chaque utilisateurs ,merci a vous d'avance

    Pour ceux que ca intéressent je fais une copie de celui-ci:

    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
    85
    86
    87
    88
    89
    90
    91
    92
    93
    'Set the amount of pst-files you want to copy. Start counting at 0!
    ReDim pst(0)
     
     
    'Define the location of each pst-file to backup. Increase the counter!
    pst(0) = "D:\bbt72\USERS\" & Username & "[/COLOR]\Documents\Fichiers Outlook\archive.pst"
     
    'Define your backup location
    BackupPath = "\\w11660100ACF\install\archive_outlook\"
     
     
    'Keep old backups? TRUE/FALSE
    KeepHistory = FALSE
     
    'Maximum time in milliseconds for Outlook to close on its own
    delay = 30000 'It is not recommended to set this below 8000
     
    'Start Outlook again afterwards? TRUE/FALSE
    start = TRUE
     
    '----------------------------------------------------------------------------------------
    ' **** POPUP AVERTISSEMENT *****
    '----------------------------------------------------------------------------------------
     
    MsgBox "Sauvegarde de vos mails en cours, Outlook sera ouvert automatiquement à la fin de la sauvegarde.Copie en cours de votre archive vers le NAS. Ne pas fermer cette fenêtre. Patienter SVP..."
     
    '----------------------------------------------------------------------------------------
    ' **** COPIE PST EN BACKUP SUR SERVEUR ****
    '----------------------------------------------------------------------------------------
    'Close Outlook
    Call CloseOutlook(delay)
     
    'Outlook is closed, so we can start the backup
    Call BackupPST(pst, BackupPath, KeepHistory)
     
    'Open Outlook again when desired.
    If start = TRUE Then
      Call OpenOutlook()
    End If
     
     
    Sub CloseOutlook(delay)
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     
      'If Outlook is running, let it quit on its own.
      For Each Process in objWMIService.InstancesOf("Win32_Process")
        If StrComp(Process.Name,"OUTLOOK.EXE",vbTextCompare) = 0 Then
          Set objOutlook = CreateObject("Outlook.Application")
          objOutlook.Quit
          WScript.Sleep delay
          Exit For
        End If
      Next
     
      'Make sure Outlook is closed and otherwise force it.
      Set colProcessList = objWMIService.ExecQuery _
      ("Select * from Win32_Process Where Name = 'Outlook.exe'")
      For Each objProcess in colProcessList
        objProcess.Terminate()
      Next
      Set objWMIService = Nothing
      Set objOutlook = Nothing
      set colProcessList = Nothing
    End Sub
     
     
    Sub BackupPST(pst, BackupPath, KeepHistory)
      Set fso = CreateObject("Scripting.FileSystemObject")
     
      If KeepHistory = True Then
        ArchiveFolder = Year(Now) & "-" & Month(Now) & "-" & Day(Now)
        BackupPath = BackupPath & ArchiveFolder & "\"
      End If
     
      If fso.FolderExists(BackupPath) = False Then
        fso.CreateFolder BackupPath
      End If
     
      For Each pstPath in pst
        If fso.FileExists(pstPath) Then
          fso.CopyFile pstPath, BackupPath, True
        End If
      Next
      Set fso = Nothing
    End Sub
     
     
    Sub OpenOutlook()
      Set objShell = CreateObject("WScript.Shell")
      objShell.Run "Outlook.exe"
    End Sub

  2. #2
    Expert confirmé

    Homme Profil pro
    Responsable déploiement (SCCM, InTune, GPO)
    Inscrit en
    Juillet 2014
    Messages
    3 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Responsable déploiement (SCCM, InTune, GPO)
    Secteur : Transports

    Informations forums :
    Inscription : Juillet 2014
    Messages : 3 184
    Points : 5 755
    Points
    5 755
    Par défaut
    Voici qui devrait te permettre d'avancer.
    Il ne te reste plus qu'a exclure ceux que tu ne souhaite pas.

    Code vbs : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder("C:\Users")
    For Each fs in f.SubFolders
    	msgbox fs.name
    Next

  3. #3
    Candidat au Club
    Homme Profil pro
    Collégien
    Inscrit en
    Février 2017
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Collégien

    Informations forums :
    Inscription : Février 2017
    Messages : 4
    Points : 3
    Points
    3
    Par défaut
    Merci beaucoup pour votre réponse , c 'était la bonne voie et le script fonctionne ,encore merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. probleme de chemin d'accès
    Par Liloo14 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 02/11/2012, 15h23
  2. [XL-2003] permettre à l'utilisateur de modifier une variable chemin sans accès au code
    Par goldfinger13 dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 05/11/2011, 18h21
  3. Réponses: 1
    Dernier message: 19/05/2006, 19h57
  4. Probleme de chemin d'acces avec batch
    Par kernerteam dans le forum Autres Logiciels
    Réponses: 4
    Dernier message: 28/04/2006, 16h45
  5. probleme de chemin d'acces avec aspSmartUpload
    Par julio_097 dans le forum ASP
    Réponses: 2
    Dernier message: 22/08/2005, 16h53

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