From: MikeB on 17 Apr 2010 00:40 I'm trying to get into understanding scripting and I have a book "Microsoft Windows Scripting self-paced Learning Guide" by Ed Wilson. The second example in the book is the following: Option Explicit 'On Error Resume Next Dim objShell Dim regActiveComputerName, regComputerName, regHostName Dim ActiveComputerName, ComputerName, HostName regActiveComputerName = "HKLM\SYSTEM\CurrentControlSet\Control \ComputerName\ActiveComputerName" 'Wscript.Echo regActiveComputerName regComputerName = "HKLM\System\CurrentControlSet\" & _ "ComputerName\ActiveComutername\Computername\" regHostName = "HKLM\System\CurrentControlSet\Control\" & _ "Services\Tcpip\Parameters\Hostname" Set objShell = CreateObject("Wscript.Shell") ActiveComputername = objShell.RegRead(regActiveComputerName) Computername = objShell.RegRead(regComputerName) HostName = objShell.RegRead(regHostName) Wscript.Echo activeComputername & " is ActiveComputerName." Wscript.Echo ComputerName & " is ComputerName." Wscript.Echo HostName & " is host name." If I try and run this on my Vista Ultimate system, I get a pop-up error messsage saying: "Error unable to open registry key" The error code is 80070002 and the source is WshShell.RegRead. I've verified that the key exists in my registry and have copied it from the registry. Still same error. No hits on Google. Any help? Thanks a lot.
From: MikeB on 17 Apr 2010 01:01 On Apr 16, 11:40 pm, MikeB <mpbr...(a)gmail.com> wrote: > I'm trying to get into understanding scripting and I have a book > "Microsoft Windows Scripting self-paced Learning Guide" by Ed Wilson. > > The second example in the book is the following: > Doh. Sorry, posting here must have been the equivalent of asking for help v from a colleague. I found multiple errors and fixed them, now it's working hunky-dory. Will teach me to try and learn stuff sitting in the doctor's waiting room. :)
From: LikeToCode on 17 Apr 2010 11:48 Glad you figured it out! Download the script56.chm help file it is a great resource and come back if you get stuck. http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
From: MikeB on 17 Apr 2010 15:09 On Apr 17, 10:48 am, LikeToCode <LikeToC...(a)discussions.microsoft.com> wrote: > Glad you figured it out! Download the script56.chm help file it is a great > resource and come back if you get stuck.http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207... Thank you - that was useful And will be useful in the future as well.
|
Pages: 1 Prev: From Excel VBA to vbScript Next: substring and error - why? |