begin process at 2012 02 12 05:37:34
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Visual Basic 6

 > 

Langages dérivés

 > 

VBScript

 > 

Affichage avec Wscript.Echo


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Affichage avec Wscript.Echo

dimanche 15 juin 2008 à 01:57:13 | Affichage avec Wscript.Echo

Leo_Robotic_Passion

Membre Club

Bonsoir a tous,

Pourriez vous me dire si il est possible d'afficher les infos de ce vbs sur un seul Wscript.Echo et non pas sur 4, comme c'est le cas actuellement?

Et si oui comment ? ^^
Merci

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings 
Wscript.Echo "OS Name: " & objOperatingSystem.Name & vbcrlf & _
"Version: " & objOperatingSystem.Version & vbcrlf & _
"Service Pack: " & objOperatingSystem.ServicePackMajorVersion & _
"." & objOperatingSystem.ServicePackMinorVersion & vbcrlf & _
"OS Manufacturer: " & objOperatingSystem.Manufacturer & vbcrlf & _
"Windows Directory: " & objOperatingSystem.WindowsDirectory & vbcrlf & _
"Locale: " & objOperatingSystem.Locale & vbcrlf & _
"Available Physical Memory: " & objOperatingSystem.FreePhysicalMemory & vbcrlf & _
"Total Virtual Memory: " & objOperatingSystem.TotalVirtualMemorySize & vbcrlf & _
"Available Virtual Memory: " & objOperatingSystem.FreeVirtualMemory & vbcrlf & _
"OS Name: " & objOperatingSystem.SizeStoredInPagingFiles
Next
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
Wscript.Echo "System Name: " & objComputer.Name & vbcrlf & _
"System Manufacturer: " & objComputer.Manufacturer & vbcrlf & _
"System Model: " & objComputer.Model & vbcrlf & _
"Time Zone: " & objComputer.CurrentTimeZone & vbcrlf & _
"Total Physical Memory: " & objComputer.TotalPhysicalMemory
Next
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_Processor")
For Each objProcessor in colSettings 
Wscript.Echo "System Type: " & objProcessor.Architecture & vbcrlf & _
"Processor: " & objProcessor.Description
Next
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_BIOS")
For Each objBIOS in colSettings 
Wscript.Echo "BIOS Version: " & objBIOS.Version
Next

dimanche 15 juin 2008 à 11:45:39 | Re : Affichage avec Wscript.Echo

JMO

Membre Club
Réponse acceptée !


 Bonjour,

En passant par une variable:

strComputer = "."
Dim strResult
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
    strResult = "OS Name: " & objOperatingSystem.Name & vbcrlf & _
                "Version: " & objOperatingSystem.Version & vbcrlf & _
                "Service Pack: " & objOperatingSystem.ServicePackMajorVersion & _
                "." & objOperatingSystem.ServicePackMinorVersion & vbcrlf & _
                "OS Manufacturer: " & objOperatingSystem.Manufacturer & vbcrlf & _
                "Windows Directory: " & objOperatingSystem.WindowsDirectory & vbcrlf & _
                "Locale: " & objOperatingSystem.Locale & vbcrlf & _
                "Available Physical Memory: " & objOperatingSystem.FreePhysicalMemory & vbcrlf & _
                "Total Virtual Memory: " & objOperatingSystem.TotalVirtualMemorySize & vbcrlf & _
                "Available Virtual Memory: " & objOperatingSystem.FreeVirtualMemory & vbcrlf & _
                "OS Name: " & objOperatingSystem.SizeStoredInPagingFiles
Next

Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
    strResult = strResult & vbCrLf &  _
                "System Name: " & objComputer.Name & vbcrlf & _
                "System Manufacturer: " & objComputer.Manufacturer & vbcrlf & _
                "System Model: " & objComputer.Model & vbcrlf & _
                "Time Zone: " & objComputer.CurrentTimeZone & vbcrlf & _
                "Total Physical Memory: " & objComputer.TotalPhysicalMemory
Next

Set colSettings = objWMIService.ExecQuery ("Select * from Win32_Processor")
For Each objProcessor in colSettings
    strResult = strResult & vbCrLf & _
                "System Type: " & objProcessor.Architecture & vbcrlf & _
                "Processor: " & objProcessor.Description
Next

Set colSettings = objWMIService.ExecQuery ("Select * from Win32_BIOS")
For Each objBIOS in colSettings
    strResult = strResult & vbCrLf &  "BIOS Version: " & objBIOS.Version
Next
WScript.Echo strResult
Set objWMIService = Nothing
Set colSettings = Nothing



jean-marc
dimanche 15 juin 2008 à 12:46:07 | Re : Affichage avec Wscript.Echo

Leo_Robotic_Passion

Membre Club

Ok j'ai pigé ! ^^

Merci beaucoup Jean-Marc

dimanche 15 juin 2008 à 21:49:07 | Re : Affichage avec Wscript.Echo

Leo_Robotic_Passion

Membre Club

Bonsoir,

J'ai tenté de récupérer l'adresse IP comme ceci :

Set colAdapters = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objAdapter in colAdapters
strResult = strResult & vbCrLf &  "IP address:" & objAdapter.IPAddress
Next

Un message d'erreur me dit type incompatible
Code 800A000D
Je ne voix pas ou je fait erreur !
Un peux d'aide SVP ?

dimanche 15 juin 2008 à 23:22:42 | Re : Affichage avec Wscript.Echo

JMO

Membre Club


 Bonsoir,

Possibilité d'affiner la recherche de l'IP.

On Error Resume Next
Set colAdapters = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).ExecQuery _
   ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True")
If Err.Number <> 0 Then
   WScript.Echo "IP inconnue"
Else
   For Each objAdapter in colAdapters
       If InStr(objAdapter.Description,"WAN") Then
          WScript.Echo "Adresse IP"  & vbTab & objAdapter.IPAddress(0) & vbCrLf & _
                       "DNSHostName" & vbTab & objAdapter.DNSHostName 
       End if
   Next
End If
Set colAdapters = Nothing



jean-marc


Cette discussion est classée dans : vbcrlf, wscript, echo, objoperatingsystem, colsettings


Répondre à ce message

Sujets en rapport avec ce message

lire un xml avec vbs [ par ElPiojo ] Bonjour,J'ai de gros probleme pour recuperer les données dans un fichier xml.Voila mon code : Option Explicit Dim xmlDoc : Set xmlDoc = CreateObject( Déclaration de variables / VBS [ par magnum42 ] Bonjour,   Je suis en train de coder un script VBS qui cherche certains évènements dansl'eventlog de serveurs distants. Il n'est pas fini, mais il fon Ping VBS et WMI [ par flopad ] Bonjour, j'ai le code suivant :If Wscript.Arguments.Count = 0 Then    Wscript.Echo "You must enter the computer name when starting this script."    Ws problème de copier(excel) / coller(mailto) [ par JMO ] Bonjour,J'avais déjà posté mon petit problème sur le Forum, mais hélas, pour moi, pas de réponse.En vbs, j'arrive à faire un copier de x range (fichie Liste Permissions sur partages [ par jubustar21 ] Bonjour,j'ai beau chercher je ne trouve pas et j'en deviens à me demander si ce que je veux est possible... O_oVoilà, je peux lister les partages sur PB ecriture dans fichier [ par ben008 ] Bonjour ,J'ai recuperer un script VBS de ce cher JCB :D modifié afin de mettre une liste d'imprimantes des differents serveurs d'impressions dans un f Retrouver le numero serie d'un pc [ par mute7145 ] Bonjour, je cherche le moyen de retrouver le numero de serie de mon pc En utilisant pas mal de logiciel et dernierment WMICodeCreator avec le script s [Déplacé VB6 --> VBS] Lister les fichiers et répertoires d'un dossier [ par axlemush ] Bonjours, j'éssaye de créer une applicationn en VBScript qui liste les fichiers et dossiers/sous-dossiers/ect ... d'un répertoire. Mais mon script bug ereur commande set [ par kipetro ] Bonjour, j'ai une ereur au moment de la commande Set sur ce script, vous seriez m'aidé?:Option explicitOn Error Resume NextConst ONE_HOUR = 3600000dim Sript qui fonctione sous vista, erreur sous xp [ par narco4 ] Bonsoir chers amis,j'ai un prb avec un script.vbs qui fonctionne sous vista, erreur sous xp alors que le fichier en question est present!script.vbs so


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,527 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales