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 :

Ajouter un FTP dans emplacements réseau


Sujet :

Scripts/Batch

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Février 2021
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Février 2021
    Messages : 1
    Par défaut Ajouter un FTP dans emplacements réseau
    Bonjour,

    Je cherche a créer un batch me permettant d'ajouter un serveur FTP dans les emplacements réseau.

    A la main j'arrive bien a créer un emplacement réseau pour accéder à un FTP à l'aide de "choisissez un emplacement réseau personnalisé" mais impossible de trouver comment faire avec batch...

    J'ai cherché dans la base de registre je trouve bien les clefs contenants le mot de passe du FTP mais rien concernant la définition de cet emplacement. Et dans le répertoire courant de l'utilisateur je ne trouve rien non plus...

    Merci d'avance pour votre aide.

  2. #2
    Expert confirmé

    Homme Profil pro
    Responsable déploiement (SCCM, InTune, GPO)
    Inscrit en
    Juillet 2014
    Messages
    3 218
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    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 218
    Par défaut
    Je ne croit pas qu'il existe une commande qui te permette de le faire directement.

    A savoir :
    Les "Emplacement réseau" sont stocké ici : %AppData%\Microsoft\Windows\Network Shortcuts
    Chaque emplacement réseau possède un dossier et une structure spécial (desktop.ini, target.lnk, attribut...)
    Une cible FTP complète est écrite comme ceci : fpt://user:password@host:port/path (exemple : ftp://toto:motdepasse@server1213.info.dns:25/dossier/sousdossier)

    La batch n'ayant pas de commande pour créer un raccourci (a ma connaissance) nous allons plutôt utiliser un vbs
    Je ne vais pas réinventer la roue puisque quelqu'un la déjà fait (source), j'ai testé le script et ça fonctionne bien:

    Code vbs : 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
    Function CreateNetworkLocation( networkLocationName, networkLocationTarget )
        Const ssfNETHOOD  = &H13&
        Const fsATTRIBUTES_READONLY = 1
        Const fsATTRIBUTES_HIDDEN = 2
        Const fsATTRIBUTES_SYSTEM = 4
    
        CreateNetworkLocation = False 
    
        ' Instantiate needed components
        Dim fso, shell, shellApplication
            Set fso =               WScript.CreateObject("Scripting.FileSystemObject")
            Set shell =             WScript.CreateObject("WScript.Shell")
            Set shellApplication =  WScript.CreateObject("Shell.Application")
    
        ' Locate where NetworkLocations are stored
        Dim nethoodFolderPath, networkLocationFolder, networkLocationFolderPath
            nethoodFolderPath = shellApplication.Namespace( ssfNETHOOD ).Self.Path
    
        ' Create the folder for our NetworkLocation and set its attributes
            networkLocationFolderPath = fso.BuildPath( nethoodFolderPath, networkLocationName )
            If fso.FolderExists( networkLocationFolderPath ) Then 
                Exit Function 
            End If 
            Set networkLocationFolder = fso.CreateFolder( networkLocationFolderPath )
            networkLocationFolder.Attributes = fsATTRIBUTES_READONLY
    
        ' Write the desktop.ini inside our NetworkLocation folder and change its attributes    
        Dim desktopINIFilePath
            desktopINIFilePath = fso.BuildPath( networkLocationFolderPath, "desktop.ini" )
            With fso.CreateTextFile(desktopINIFilePath)
                .Write  "[.ShellClassInfo]" & vbCrlf & _ 
                        "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" & vbCrlf & _ 
                        "Flags=2" & vbCrlf
                .Close
            End With 
            With fso.GetFile( desktopINIFilePath )
                .Attributes = fsATTRIBUTES_HIDDEN + fsATTRIBUTES_SYSTEM
            End With 
    
        ' Create the shortcut to the target of our NetworkLocation
        Dim targetLink
            targetLink = fso.BuildPath( networkLocationFolderPath, "target.lnk" )
            With shell.CreateShortcut( targetLink )
                .TargetPath = networkLocationTarget
                .Save
            End With        
    
        ' Done
            CreateNetworkLocation = True 
    
    End Function
    
    CreateNetworkLocation "Mon FTP server1213.info.dns", "ftp://toto:motdepasse@server1213.info.dns:25/dossier/sousdossier"

Discussions similaires

  1. ne pas autoriser l'ajout de fichier dans ftp
    Par Invité dans le forum Administration système
    Réponses: 7
    Dernier message: 14/02/2012, 16h38
  2. [WS 2008] Ajouté une entrée pour le site FTP dans le serveur DNS
    Par Midou45 dans le forum Windows Serveur
    Réponses: 2
    Dernier message: 29/04/2011, 15h46
  3. ajouter une jpanel dans le bon emplacement dans une jframe
    Par jlassiramzy dans le forum Agents de placement/Fenêtres
    Réponses: 1
    Dernier message: 31/07/2006, 17h37

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