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

VB 6 et antérieur Discussion :

[VB]Problème d'exécution d'une commande dos...


Sujet :

VB 6 et antérieur

  1. #1
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut [VB]Problème d'exécution d'une commande dos...
    Salut,
    J'essaie d'exécuter une commande dos, qui testée à part fonctionne... Lorsque je veux tenter de l'exécuter comme suit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Shell "command.com reg load hku\mynewhive c:\ntuser.dat"
    Il me dit dans la fenêtre dos "too many parameters". Hors, quand je suis dans cmd.exe, pas de problème d'exécution... Par contre, quand je suis dans une fenêtre command.com, pas moyen... Que puis-je faire???

  2. #2
    Membre régulier
    Inscrit en
    Septembre 2003
    Messages
    91
    Détails du profil
    Informations forums :
    Inscription : Septembre 2003
    Messages : 91
    Points : 95
    Points
    95
    Par défaut
    Bonjour,
    Peut être que tu peux créer un fichier bat contenant ta commande DOS et exécuter le fichier BAT avec un shell.

  3. #3
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    Je viens de retester, lorsque je fais
    run => cmd , ma commande dos, tout passe sans probème...
    run => Command.com , ma commande dos, tout passe sans probème...
    Par contre, dans la fenêtre command.com ouvert par mon code, 'reg' is not recognize as an internal command... Je comprend rien... D'autant qu'hier, ça fonctionnait...

  4. #4
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    de plus, le prompt de cette fenêtre n'est pas c:\> mais juste c> Quelqu'un sait me dire comment ça se fait??? Manque-t-il une référence ou...

  5. #5
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Essaie ça
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
         Call Shell("cmd /c reg load hku\mynewhive c:\ntuser.dat")
    Ne me demande pas pourquoi le /c est nécessaire, mais dans l'exemple pris comme exemple, il l'est...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
        Call Shell("cmd /c Ipconfig > c:\EssaiIP.txt")
    Tu nous dis

    A+

    Edit
    L'histoire du prompt : En dos, il est possible de définir le prompt. Il peut donc prendre plusieurs formes. A toi d'adapter la commande

  6. #6
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Et pourquoi veux-tu ouvrir command.com?

  7. #7
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    Je veux pas spécialement ouvrir command.com mais juste exécuter une commande dos...
    Pour ce qui est du paramètre \c, je peux par contre dire qu'i sert à refermer la fenêtre automatiquement après exécution de la commande...

  8. #8
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Ben, tu peux lancer reg.exe sans passer par command.com, non?

  9. #9
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Pour info:

    COMMAND

    Starts a new instance of the MS-DOS command interpreter.

    A command interpreter is a program that lets you type commands. Use the EXIT
    command to stop the new command interpreter and return control to the old
    one.

    Syntax
    COMMAND [[drive:]path] [device] [/E:nnnnn] [/Y [/C command|/K command]]

    In your CONFIG.SYS file, use the following syntax:

    SHELL=[[dos-drive:]dos-path]COMMAND.COM [[drive:]path][device]
    [/E:nnnn] [/P [/MSG]]

    Parameters

    [drive:]path
    Specifies the directory in which the command interpreter is to look for
    the COMMAND.COM file when the transient part of the program needs to be
    reloaded. This parameter must be included when loading COMMAND.COM for
    the first time if the COMMAND.COM file is not located in the root
    directory. This parameter is used to set the COMSPEC environment
    variable. For more information, see Transient and Resident Memory in
    <COMMAND--Notes>.

    device
    Specifies a different device for command input and output. For more
    information about this parameter, see the <CTTY> command.

    [dos-drive:]dos-path
    Specifies the location of the COMMAND.COM file.

    Switches

    /C command
    Specifies that the command interpreter is to perform the specified
    command and then exit. This switch must be the last switch on the
    command line.

    /E:nnnnn
    Specifies the environment size, where nnnnn is the size in bytes. The
    value of nnnnn must be in the range 160 through 32768. MS-DOS rounds
    this number up to a multiple of 16 bytes. The default value is 256.

    /K command
    Runs the specified command, program, or batch program and then displays
    the MS-DOS command prompt. This switch must be the last switch on the
    COMMAND command line.

    This switch is particularly useful for specifying a startup batch file
    for the MS-DOS Prompt in Windows (much like AUTOEXEC.BAT for MS-DOS). To
    do this, open the DOSPRMPT.PIF file using the PIF Editor, and type the
    /K switch in the Optional Parameters box. It is not recommended to use
    the /K switch on the SHELL command line in your CONFIG.SYS file; doing
    so can cause problems with applications and installation programs that
    make changes to your AUTOEXEC.BAT file.

    /P
    Should be used only when COMMAND is used with the SHELL command in the
    CONFIG.SYS file. The /P switch makes the new copy of the command
    interpreter permanent. In this case, the EXIT command cannot be used to
    stop the command interpreter. If you specify /P, MS-DOS runs your
    AUTOEXEC.BAT file before displaying the command prompt. If there is no
    AUTOEXEC.BAT file in the root directory of the startup drive, MS-DOS
    carries out the DATE and TIME commands instead. If you do not have a
    SHELL command in your CONFIG.SYS file, COMMAND.COM is automatically
    loaded from the root directory with the /P switch.

    /MSG
    Specifies that all error messages should be stored in memory. Usually,
    some messages are stored only on disk. This switch is useful only if you
    are running MS-DOS from floppy disks. You must specify the /P switch
    when you use the /MSG switch. For more information about using the /MSG
    switch, see <COMMAND--Notes>.
    /Y
    Directs COMMAND.COM to step through the batch file specified by the /C
    or /K switches. This switch is useful for debugging batch files. For
    example, to step through the TEST.BAT batch file line by line, you would
    type COMMAND /Y /C TEST. The /Y switch requires either the /C or the /K
    switch.

    Related Command

    The <SHELL> command is the preferred method of using COMMAND to permanently
    increase space for the environment table.

  10. #10
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    Je viens de réessayer... J'ai testé en même temps la commande avec l'ip... Celle-là s'éxécute, la mienne, non... Hors, lorsque je la tape directement sous dos, ça fonctionne...

  11. #11
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Et en mettant reg.exe à la place de reg, ça passe pas mieux?

  12. #12
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    Nop... Absolument pas... Je comprends rien de rien d'autant qu'il y a 24heures à peu près, je notais ce morceau de code dans le forum après l'avoir testé et vu fonctionner...

  13. #13
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Juste une idée
    Si Reg.exe n'est pas une commande dos mais un simple exécutable, le chemin peut être nécessaire.

    A tout hasard

    A+

    PS - Merci Alain, pour la description de command

  14. #14
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    Ca fonctionne toujours pas...

  15. #15
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 546
    Points
    15 546
    Par défaut
    Bon, une question : Que veux-tu faire, il existe peut-être une autre solution...

    A+

  16. #16
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    En fait, j'aimerais que ma commande dos s'exécute... Mais je ne peux laisser aucun fichier derrière moi sur le disque... La seule chose que je veux arriver à faire, c'est monter un ruche, via la commande reg load... Ou une autre si il en existe une...

  17. #17
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Je viens d'essayer.

    Même type d'erreur.

    J'ai remplacé command par cmd...

  18. #18
    Membre actif Avatar de Empty_body
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    681
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 681
    Points : 239
    Points
    239
    Par défaut
    et ça a fonctionné??? Une ruche s'est ajoutée dans regedit hkey_users???

  19. #19
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Désolé, mon essai (pour mes besoins) se portait sur la suppression d'une clé.

    J'ai pas testé pour le chargement d'une ruche.

  20. #20
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Je vais répéter ma question.

    Pourquoi veux-tu lancer command puisque tu fermes la fenêtre à la fin de l'exécution?

    Pourquoi ne lances-tu pas reg depuis le shell?

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. > Exécution d'une commande Dos dans un programme Java
    Par siempre dans le forum Débuter
    Réponses: 1
    Dernier message: 08/01/2012, 10h26
  2. Exécution d'une commande DOS dans un programme Java
    Par siempre dans le forum Débuter avec Java
    Réponses: 1
    Dernier message: 08/01/2012, 02h07
  3. Réponses: 3
    Dernier message: 10/09/2009, 11h08
  4. Exécution d'une commande DOS
    Par gobgob dans le forum VBScript
    Réponses: 6
    Dernier message: 19/09/2007, 12h23
  5. [VB.NET] exécuter une command Dos à Partir de Vb.Net
    Par Khalid.bounouader dans le forum Windows Forms
    Réponses: 4
    Dernier message: 27/12/2006, 14h05

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