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 :

[VBS] Erreur sur "AddWindowsPrinterConnection"


Sujet :

VBScript

  1. #1
    Expert confirmé

    Profil pro
    Inscrit en
    Avril 2002
    Messages
    3 338
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Avril 2002
    Messages : 3 338
    Points : 4 657
    Points
    4 657
    Par défaut [VBS] Erreur sur "AddWindowsPrinterConnection"
    Bonjour,

    J'essaye en vain de rajouter automatiquement une imprimante via un script VBS :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Set WshNetwork = CreateObject("WScript.Network")
    PrinterPath = "\\aval-srv\Epson_1290"
    PrinterDriver = "EPSON Stylus Photo 1290"
    Set rc = WshNetwork.AddWindowsPrinterConnection(PrinterPath, PrinterDriver)
    If Not rc then
          WScript.Echo("Échec de connexion de l'imprimante")
    End If
    Mais il plante à la ligne 4 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Set rc = WshNetwork.AddWindowsPrinterConnection(PrinterPath, PrinterDriver)
    Avec le message :
    Citation Envoyé par L'affreux script
    Script : D:\Installation\VBS\Test.vbs
    Ligne : 4
    Caract. : 1
    Erreur : Syntaxe du nom de fichier, de répertoire ou de volume incorrecte.
    Code : 8007007B
    Source : (null)
    Et je suis completement bloqué ici.

    Merci d'avance ;-)

  2. #2
    Expert confirmé

    Profil pro
    Inscrit en
    Avril 2002
    Messages
    3 338
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Avril 2002
    Messages : 3 338
    Points : 4 657
    Points
    4 657
    Par défaut
    J'ai trouvé :
    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
    Dim objNet
    Dim objShell
     
    Set objNet = CreateObject("Wscript.Network")    
    Set objShell = WScript.CreateObject("WScript.Shell")
     
    If objShell.ExpandEnvironmentStrings("%OS%") = "" Then
    	'Windows 95/98/ME
    	objNet.AddWindowsPrinterConnection "\\aval-srv\EPSON_1290","EPSON Stylus Photo 1290"
    	objNet.AddWindowsPrinterConnection "\\aval-srv\Traceur","HP DesignJet 650C(C2859B) by HP"
    	objNet.AddWindowsPrinterConnection "\\aval-srv\HP_1120C","HP DeskJet 1120C"
    Else
    	'Windows 2000/XP
    	objNet.AddWindowsPrinterConnection "\\aval-srv\EPSON_1290"
    	objNet.AddWindowsPrinterConnection "\\aval-srv\Traceur"
    	objNet.AddWindowsPrinterConnection "\\aval-srv\HP_1120C"
    End If
     
    'Les disques Réseaux
    objNet.MapNetworkDrive "F:", "\\aval-srv\echange",True
    objNet.MapNetworkDrive "G:", "\\aval-srv\echange",True
    objNet.MapNetworkDrive "P:", "\\aval-srv\echange",True
    C'est des syntaxes différentes suivant les windows :-)

  3. #3
    Expert éminent
    Avatar de ThierryAIM
    Homme Profil pro
    Inscrit en
    Septembre 2002
    Messages
    3 673
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2002
    Messages : 3 673
    Points : 8 524
    Points
    8 524
    Par défaut
    Joli Goshiz, on garde
    Vous vous posez une question, la réponse est peut-être ici :
    Toutes les FAQs VB
    Les Cours et Tutoriels VB6/VBScript
    Les Sources VB6


    Je ne réponds pas aux questions techniques par MP. Utilisez les forums. Merci de votre compréhension

  4. #4
    Expert confirmé

    Profil pro
    Inscrit en
    Avril 2002
    Messages
    3 338
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Avril 2002
    Messages : 3 338
    Points : 4 657
    Points
    4 657
    Par défaut
    ok alors je corrige l'énorme faute que j'ai vu après

    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
    Dim objNet 
    Dim objShell 
     
    'Un Petit Resume pour l'erreur.
    On Error Resume Next
     
    Set objNet = CreateObject("Wscript.Network")    
    Set objShell = WScript.CreateObject("WScript.Shell") 
     
    If objShell.ExpandEnvironmentStrings("%OS%") = "Windows_NT" Then 
       'Windows 2000/XP 
       objNet.AddWindowsPrinterConnection "\\aval-srv\EPSON_1290" 
       objNet.AddWindowsPrinterConnection "\\aval-srv\Traceur" 
       objNet.AddWindowsPrinterConnection "\\aval-srv\HP_1120C" 
    Else 
       'Windows 95/98/ME 
       objNet.AddWindowsPrinterConnection "\\aval-srv\EPSON_1290","EPSON Stylus Photo 1290" 
       objNet.AddWindowsPrinterConnection "\\aval-srv\Traceur","HP DesignJet 650C(C2859B) by HP" 
       objNet.AddWindowsPrinterConnection "\\aval-srv\HP_1120C","HP DeskJet 1120C" 
    End If 
     
    'Les disques Réseaux 
    objNet.MapNetworkDrive "F:", "\\aval-srv\echange",True 
    objNet.MapNetworkDrive "G:", "\\aval-srv\echange",True 
    objNet.MapNetworkDrive "P:", "\\aval-srv\echange",True

  5. #5
    Candidat au Club
    Inscrit en
    Mars 2004
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 2
    Points : 2
    Points
    2
    Par défaut erreur
    erreur

  6. #6
    Candidat au Club
    Inscrit en
    Mars 2004
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    Bonjour
    J'ai refait ce meme scripte sur un serveur 2000 avec une imprimante partagée sur ce meme serveur avec le nom HP2200SDP et pourtant la meme erreur persiste :

    Erreur : Syntaxe du nom de fichier, de répertoire ou de volume incorrecte.
    Ligne 2
    caractere 1


    Pourquoi ? Merci de votre aide ...
    Si je mets n'importe quoi comme chemin d'imprimante, il me dit "le nom de l'imprimante n'est pas valide" donc mon chemin unc est bon ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Set objNet = Wscript.CreateObject("Wscript.Network")    
    objNet.AddWindowsPrinterConnection "\\serveur\HP2200SDP"

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

Discussions similaires

  1. [Quote] DVP quoté sur Bashfr
    Par Skyounet dans le forum La taverne du Club : Humour et divers
    Réponses: 16
    Dernier message: 26/09/2006, 18h52

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