Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21119

VB script not fectching registry data

$
0
0
Hi All,

I am new to the VB world. I am writing my first script to fetch data from registry. OS is Windows 7.

Option Explicit
On Error Resume Next
Dim objshell
Dim regactivecomputername,regcomputername,reghostname
Dim activecomputername,computername,hostname

regactivcomputername = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerNam e"
regcomputername = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
reghostname = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\HostName"

Set objshell = CreateObject(WScript.Shell)
activecomputername= objshell.ReadReg(regactivcomputername)
computername= objshell.ReadReg(computername)
hostname= objshell.ReadReg(hostname)

WScript.Echo activecomputername &"is active computer name"
WScript.Echo computername &"is computer name"
WScript.Echo hostname &"is host name"[/B]But system not fecthing data from refgistry. It only shows is active computer name Etc.

Is there anything needs to be installed for windows 7 or how to go about this.

Please help.

Viewing all articles
Browse latest Browse all 21119

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>