title: How do I get the computer name of a system and output it to a file in VBScript
body: <p>I am trying to get the computer name from the registry and write it to a file. At this point, my function call for obtaining the computer name from registry isn't working. Any advice would be appreciated.</p>
  
  <pre><code>Option Explicit
  On Error Resume Next
  
  Dim regComputerName, ComputerName
  
  Set objShell = WScript.CreateObject("WScript.Shell")
  Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  
  regComputerName = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\Computername"
  ComputerName = obj.shell.RegRead(regComputerName)
  
  oWrite.WriteLine(ComputerName,C:\text)
  </code></pre>