Windows
Scripts
VBScript
Récupérer le nom de l'ordinateur
Pour : Windows
Nous allons voir 2 méthodes pour obtenir le nom de l'ordinateur avec un script VBS.
Voici un exemple pour illustrer la 1ère méthode pour afficher le nom de l'ordinateur.
Exemple:
'*** Création de l'environnement
Set Shell = CreateObject("wscript.Shell")
Set env = Shell.environment("Process")
strComputer = env.Item("Computername")
'*** Affichage du nom de l'ordinateur
wscript.echo strComputer
'*** Destruction des objets
Set Shell = Nothing
Set env = Nothing
WScript.Quit
'*** Création de l'environnement
Set oNet = WScript.CreateObject("WScript.Network")
'*** Affichage du nom de l'ordianteur
WScript.Echo "Computer Name = " & oNet.ComputerName
'*** Destruction des objets
Set oNet = Nothing
WScript.Quit
