Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : Affichage avec Wscript.Echo [ Langages dérivés / VBScript ] (Leo_Robotic_Passion)

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é 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 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 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 Wscript.Write "coucou" ou Wscript.Echo "coucou" [ par Casdale ] Voici mon probleme lorsque j'execute Wscript.echo "lalallalalal"mon code marche parfaitementmais lorsque que j' execute Wscript.Write "lalal"le co


Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Téléchargements

Logiciels à télécharger sur le même thème :

Comparez les prix Nouvelle version

Photothèque Nouveau !



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
Temps d'éxécution de la page : 0,546 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.