Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
898 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  VBS Commande externe

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

VBS Commande externe

n°1147989
JuVeNaL
Carpe Diem
Posté le 12-07-2005 à 15:23:59  profilanswer
 

Bonjour ,
 
Je souhaite en VBS lancer une commande Dos  
et récuperer le résultat en VBS  ?
 
Es-ce possible ? si oui avec quel fonction ou methode ?  
 
Bien à vous  
JuVeNaL

mood
Publicité
Posté le 12-07-2005 à 15:23:59  profilanswer
 

n°1148471
AlainTech
Pas trouvé? Cherche encore!
Posté le 12-07-2005 à 23:01:10  profilanswer
 

Trouvé sur le net sur http://groups.msn.com/windowsscrip [...] ortstring=
 

'---------------------------------------------------------------------
'--                          1998 © Pablo Almunia
'---------------------------------------------------------------------
'--
'--     Program : RunOutput.VBS
'-- Description : Funciont RunOutput run a programa and return the  
'--               output
'--  Parameters : cPrograma   - Command to execute
'--               nWindowType - Type of windows (same Run method of  
'--                             WScript.Shell)
'--       Notes : -
'--   Programer : Pablo Almunia
'--        Date : 03-03-1999
'--     Version : 1.0
'--     History : -
'--
'---------------------------------------------------------------------
Option Explicit
'-- Sample with a DIR
MsgBox RunOutput( "COMMAND /C DIR C:\", 0 )
 
 
'---------------------------------------------------------------------
'-- RunOutput Function
'---------------------------------------------------------------------
Function RunOutput( cProgram, nWindowType )
 
 '-- Obtain a Temporary File Name
 Dim oFS
 Set oFS = CreateObject("Scripting.FileSystemObject" )
 Dim cFile
 cFile = oFS.GetSpecialFolder(2).Path & "\" & oFS.GetTempName  
 
 '-- Execute the command and redirect the output to the file
 Dim oShell  
 Set oShell = CreateObject( "WScript.Shell" )
 oShell.Run cProgram & " >" & cFile, nWindowType, True  
 Set oShell = Nothing
 
 '-- Read output file and return
 Dim oFile
 Set oFile = oFS.OpenTextFile(cFile, 1, True)
 RunOutput = oFile.ReadAll()
 oFile.Close
 
 '-- Delete Temporary File
 oFS.DeleteFile cFile
 
End Function    
 
'--------------------------
'-- End of RunOutput.vbs --
'--------------------------
 
Credit: - 21/01/2001.


---------------
Si on vous donne une info qui marche, DITES-LE!!!! ------ Si vous trouvez seul, AUSSI, votre solution peut servir à d'autres! ------ Je dois la majorité de mes connaissances à mes erreurs!

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  VBS Commande externe

 

Sujets relatifs
Probleme attacheMovie & Classe externe[php/mysql] commande insert into
Script Vbs et formulaires dans IE[VBS] Ouvrir un fichier excel dans une feuille spécifique [Résolu]
commande sql[VBS] [WORD] Expressions régulières - Rechercher toutes les lignes...
connection a une base de donnée Acess Par VBSScript VBS : corection??
[VBS] pb recup computer dans AD[VBS]Récuperer date Windows2000
Plus de sujets relatifs à : VBS Commande externe


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR