Hi @Mayhan28 ,
You can refer to the code below for how to retrieve the computer name using various scripting techniques, you can refer to this link for details.
https://www.robvanderwoude.com/vbstech_network_names_computer.php
Environment Variable
Set wshShell = CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
WScript.Echo "Computer Name: " & strComputerName
SHGINA.DLL (Shell.LocalMachine)
Set objPC = CreateObject( "Shell.LocalMachine" )
strComputerName = objPC.MachineName
WScript.Echo "Computer Name: " & strComputerName
System Scripting Runtime
Set objLM = CreateObject( "SScripting.LMNetwork" )
strComputerName = objLM.ComputerName
WScript.Echo "Computer Name: " & ComputerName
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.