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

Scripts/Batch Discussion :

Problème pour monter "shadow copy" en FR [Batch]


Sujet :

Scripts/Batch

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Janvier 2015
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2015
    Messages : 57
    Points : 34
    Points
    34
    Par défaut Problème pour monter "shadow copy" en FR
    Bonjour à toutes et tous

    Tout d'abord tous mes voeux pour cette nouvelle année !!!
    J'ai trouvé il y a quelques temps sur ce lien : http://www.howtogeek.com/129188/htg-...-locked-files/
    Un petit script bien pratique nommé "MountLatestShadowCopy" qui permet de monter et exploiter les clichés instantanés VSS.

    Code bat : 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
    94
    95
    96
    97
    98
    @ECHO OFF
    IF NOT "%~1" == "/?" GOTO Main
     
    ECHO Mount Latest Shadow Copy [v1.0]
    ECHO Locates the most recent Windows file shadow copy and mounts it to the
    ECHO specified directory.
    ECHO Copyright (c) 2012, Jason Faulkner - All rights reserved.
    ECHO.
    ECHO %~n0 MountToFolder [SearchDrive]
    ECHO.
    ECHO  MountToFolder  Folder location where the shadow copy contents will be made
    ECHO                 available. This folder should NOT exist; it will be created
    ECHO                 as a mount point and accessible after the operation completes.
    ECHO                 Important Note: The target specified should end with 
    ECHO                 a \ character to ensure it is properly read as a directory.
    ECHO                 For example: C:\MyShadowCopy\
    ECHO  SearchDrive    Specifies the local drive for which you want to mount the
    ECHO                 latest shadow copy. Enter with a colon following the drive
    ECHO                 letter. Default value is C:.
    ECHO.
    ECHO Note: This script MUST be run as Administrator (with highest privledges in a
    ECHO       scheduled task) in order to work properly.
    ECHO.
    ECHO Requirements:
    ECHO  Windows Vista or later with System Restore enabled.
    ECHO.
    ECHO __________
    ECHO Visit my website for additional information, examples and updates.
    ECHO <a href="http://jasonfaulkner.com" target="_blank">http://jasonfaulkner.com</a>
    GOTO :EOF
     
     
    :Main
    SETLOCAL EnableExtensions
     
    CALL :Initialize
    CALL :Configuration %*
    CALL :CheckRequirements
    IF %ERRORLEVEL% GTR 0 GOTO Finish
    CALL :PrepSettings 
    IF %ERRORLEVEL% GTR 0 GOTO Finish
     
     
    REM Pull the shadow copy listing.
    VSSAdmin List Shadows %SearchDrive% > %TempFile%
     
    SET ShadowPath=
    REM Pull the latest shadow copy from the listing.
    FOR /F "usebackq tokens=1,2* delims=:" %%A IN (`FINDSTR /I /C:"Shadow Copy Volume:" %TempFile%`) DO SET ShadowPath=%%B
     
    IF NOT "%ShadowPath%" == "" (
    	REM A shadow copy was found, mount it.
    	MKLINK /D "%MountFolder%" %ShadowPath%\
    ) ELSE (
    	ECHO No Shadow Copies found.
    )
     
    :Finish
    IF EXIST %TempFile% DEL %TempFile%
    ENDLOCAL
    GOTO :EOF
     
     
    :Initialize
    SET MountFolder=
    SET SearchDrive=C:
    SET TempFile="%TEMP%\%~n0_%RANDOM%.txt"
    GOTO :EOF
     
    :Configuration
    IF /I "%~1" == "" GOTO InvalidParams
    SET MountFolder=%~dp1
    IF NOT "%~2" == "" SET SearchDrive=%~2
    GOTO :EOF
     
    :PrepSettings
    IF EXIST "%MountFolder%" (
    	ECHO Mount Folder: %MountFolder%
    	ECHO The specified folder already exists. Enter a new folder for the mount target.
    	GOTO InvalidParams
    )
    IF NOT "%SearchDrive%" == "" SET SearchDrive=/FOR=%SearchDrive%
    GOTO :EOF
     
     
    :CheckRequirements
    CALL :VerifyRequirement "vssadmin.exe"
    GOTO :EOF
     
    :VerifyRequirement
    IF EXIST "%~1" GOTO :EOF
    IF NOT "%~$PATH:1" == "" GOTO :EOF
    ECHO Missing requirement: [%~1] Use /? to view the help information.
    EXIT /B 2
     
    :InvalidParams
    ECHO Invalid parameters. Use /? to view the help information.
    EXIT /B 1

    Le script fonctionne parfaitement sur un environnement anglo-saxon mais pas sur un OS en français. Je l'ai donc modifié en remplaçant l'entrée "Shadow Copy Volume" par "Volume de cliché instantané"

    Code bat : 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
    :Main
    SETLOCAL EnableExtensions
     
    CALL :Initialize
    CALL :Configuration %*
    CALL :CheckRequirements
    IF %ERRORLEVEL% GTR 0 GOTO Finish
    CALL :PrepSettings 
    IF %ERRORLEVEL% GTR 0 GOTO Finish
     
     
    REM Pull the shadow copy listing.
    VSSAdmin List Shadows %SearchDrive% > %TempFile%
     
    SET ShadowPath=
    REM Pull the latest shadow copy from the listing.
    FOR /F "usebackq tokens=1,2* delims=:" %%A IN (`FINDSTR /I /C:"Volume de cliché instantané :" %TempFile%`) DO SET ShadowPath=%%B
     
    IF NOT "%ShadowPath%" == "" (
    	REM A shadow copy was found, mount it.
    	MKLINK /D "%MountFolder%" %ShadowPath%\
    ) ELSE (
    	ECHO No Shadow Copies found.
    )
     
    :Finish
    IF EXIST %TempFile% DEL %TempFile%
    ENDLOCAL
    GOTO :EOF
     
     
    :Initialize
    SET MountFolder=
    SET SearchDrive=C:
    SET TempFile="%TEMP%\%~n0_%RANDOM%.txt"
    GOTO :EOF
     
    :Configuration
    IF /I "%~1" == "" GOTO InvalidParams
    SET MountFolder=%~dp1
    IF NOT "%~2" == "" SET SearchDrive=%~2
    GOTO :EOF
     
    :PrepSettings
    IF EXIST "%MountFolder%" (
    	ECHO Mount Folder: %MountFolder%
    	ECHO The specified folder already exists. Enter a new folder for the mount target.
    	GOTO InvalidParams
    )
    IF NOT "%SearchDrive%" == "" SET SearchDrive=/FOR=%SearchDrive%
    GOTO :EOF
     
     
    :CheckRequirements
    CALL :VerifyRequirement "vssadmin.exe"
    GOTO :EOF
     
    :VerifyRequirement
    IF EXIST "%~1" GOTO :EOF
    IF NOT "%~$PATH:1" == "" GOTO :EOF
    ECHO Missing requirement: [%~1] Use /? to view the help information.
    EXIT /B 2

    Mais rien n'y fait j'ai toujours l'erreur "No Shadows Copies found" alors que les clichés existent bel et bien... Et là je sèche

    Est ce que quelqu'un a déjà été confronté à ce problème ?

    Merci d'avance pour votre aide

  2. #2
    Membre expert
    Avatar de sachadee
    Homme Profil pro
    AMI DU BAT
    Inscrit en
    Janvier 2013
    Messages
    1 478
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Brésil

    Informations professionnelles :
    Activité : AMI DU BAT
    Secteur : Distribution

    Informations forums :
    Inscription : Janvier 2013
    Messages : 1 478
    Points : 3 768
    Points
    3 768
    Par défaut
    Essaye juste comme ça pour tester :

    Code bat : Sélectionner tout - Visualiser dans une fenêtre à part
    FOR /F "usebackq tokens=1,2* delims=:" %%A IN (`FINDSTR /I /C:"Volume de clich" %TempFile%`) DO SET ShadowPath=%%B

    et retourne

    ________________________________
    Un p'tit coup de pouce ça fait toujours plaisir, pensez-y !
    ________________________________

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Janvier 2015
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2015
    Messages : 57
    Points : 34
    Points
    34
    Par défaut
    Citation Envoyé par sachadee Voir le message
    Essaye juste comme ça pour tester :

    Code bat : Sélectionner tout - Visualiser dans une fenêtre à part
    FOR /F "usebackq tokens=1,2* delims=:" %%A IN (`FINDSTR /I /C:"Volume de clich" %TempFile%`) DO SET ShadowPath=%%B

    et retourne

    Enooooorrrrrrme !!!! J'en pouvais plus de chercher
    Ca fonctionne à merveille.
    Comment as tu trouvé la solution ? Problème d'encodage ?

    Mille mercis

  4. #4
    Membre éclairé Avatar de devilsnake88
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2013
    Messages
    453
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2013
    Messages : 453
    Points : 809
    Points
    809
    Par défaut
    Bonjour,
    Je m'incruste hein mais je m'ennuis au boulot alors...
    Je pense que maître Sachadee voulait te faire quelque chose ou tu n'aurais pas besoin de batailler avec les encodages, du coup il spécifie dans sa recherche que des caractères "universels".

    Si tu veux changer d'encodage pour prendre en compte tes é è à etc...
    Sous Notepad ++ tu peux déjà faire un CTRL+A et CTRL+C de tout ton script, ensuite:
    Menu Encodage > Codage de caractères > Langues d'Europe occidentale > OEM 858
    Là tu CTRL+V et CTRL+S et tu echo un "é" pour voir si ça fonctionne.

    Dans tous les cas, la solution de rechercher dans caractères "spéciaux" est la solution la plus simple dans ce cas précis.
    ________________________________________________________________
    N'oublie pas de faire une sauvegarde avant d'exécuter des scripts...
    Si j'ai ton problème, un petit fait toujours plaisir!
    ________________________________________________________________

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Janvier 2015
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2015
    Messages : 57
    Points : 34
    Points
    34
    Par défaut
    Merci à vous deux pour votre aide et vos explications. Une belle épine que vous m'enlevez du pied
    Du coup je m'autorise à poser une ultime colle dans la continuité du problème rencontré
    J'essaie de monter un script qui fasse une sauvegarde de mes .pst

    Code bat : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    @echo off
    SET server=SAMISELLAMI
    SET Backup_Path=\\%server%\D$\test\
    SET Outlook_Path=D:\samisellami\Outlook_Archives
     
    If exist %Backup_Path% (goto :backup) else ( mkdir %Backup_Path% "goto :backup" )
     
    :backup
    CALL MountLatestShadowCopy D:\MyShadow\
    xcopy %Outlook_Path% %Backup_Path%
    RMDIR D:\MyShadow

    Et voilà le retour que j'ai

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Nom de répertoire non valide.
    Une erreur s'est produite lors du traitement de*: goto :backup.
    Lien symbolique créé pour D:\MyShadow\ <<===>> \\?\GLOBALROOT\Device\HarddiskVol
    umeShadowCopy3\
    D:\samisellami\Outlook_Archives\2014.pst
    Il doit y avoir des erreurs dans le script mais surtout je ne comprends pas pourquoi la fenêtre DOS reste ouverte et pourquoi le "RMDIR D:\MyShadow" ne s’exécute pas

  6. #6
    Membre éclairé Avatar de devilsnake88
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2013
    Messages
    453
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2013
    Messages : 453
    Points : 809
    Points
    809
    Par défaut
    Essaye ceci:
    Code bat : 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
     
    @echo off
    SET server=SAMISELLAMI
    SET Backup_Path=\\%server%\D$\test\
    SET Outlook_Path=D:\samisellami\Outlook_Archives
     
    If exist %Backup_Path% (
    	goto :backup
    ) else (
    	mkdir %Backup_Path%
    	goto :backup
    )
     
    :backup
    CALL MountLatestShadowCopy D:\MyShadow\
    xcopy %Outlook_Path% %Backup_Path%
    RMDIR D:\MyShadow
    goto :end
     
    :end
    echo.
    echo le script est terminé
    pause

    PS: http://www.developpez.net/forums/d14...m/#post8048104
    ________________________________________________________________
    N'oublie pas de faire une sauvegarde avant d'exécuter des scripts...
    Si j'ai ton problème, un petit fait toujours plaisir!
    ________________________________________________________________

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Janvier 2015
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2015
    Messages : 57
    Points : 34
    Points
    34
    Par défaut
    Citation Envoyé par devilsnake88 Voir le message
    Essaye ceci:
    Code bat : 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
     
    @echo off
    SET server=SAMISELLAMI
    SET Backup_Path=\\%server%\D$\test\
    SET Outlook_Path=D:\samisellami\Outlook_Archives
     
    If exist %Backup_Path% (
    	goto :backup
    ) else (
    	mkdir %Backup_Path%
    	goto :backup
    )
     
    :backup
    CALL MountLatestShadowCopy D:\MyShadow\
    xcopy %Outlook_Path% %Backup_Path%
    RMDIR D:\MyShadow
    goto :end
     
    :end
    echo.
    echo le script est terminé
    pause

    PS: http://www.developpez.net/forums/d14...m/#post8048104
    Merci !!! Tout est ok et fonctionnel

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

Discussions similaires

  1. Réponses: 6
    Dernier message: 02/05/2015, 23h06
  2. problème pour monter un cdrom
    Par javanoiid dans le forum BSD
    Réponses: 3
    Dernier message: 26/01/2011, 15h25
  3. VMWARE ESXi 4.1 - problème pour monter un cdrom
    Par tochbee dans le forum VMware
    Réponses: 4
    Dernier message: 21/01/2011, 16h28
  4. Problème pour monter le volume (mon disque dur).
    Par avion148 dans le forum Bubuntu
    Réponses: 1
    Dernier message: 02/09/2008, 16h06

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