Beginning scripting and have a problem

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.
0
MikeB
4/17/2010 4:40:16 AM
scripting.vbscript 564 articles. 0 followers. Follow

3 Replies
1052 Views

Similar Articles

[PageSpeed] 59

On Apr 16, 11:40=A0pm, MikeB <mpbr...@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.  :)

0
MikeB
4/17/2010 5:01:22 AM
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

0
Utf
4/17/2010 3:48:01 PM
On Apr 17, 10:48=A0am, LikeToCode <LikeToC...@discussions.microsoft.com>
wrote:
> Glad you figured it out! Download the script56.chm help file it is a grea=
t
> resource and come back if you get stuck.http://www.microsoft.com/download=
s/details.aspx?FamilyId=3D01592C48-207...

Thank you - that was useful And will be useful in the future as well.

0
MikeB
4/17/2010 7:09:09 PM
Reply:

Similar Artilces:

Problem with IF statement #2
I have the following set-up with 3 cells: A1 - a target percentage value (30.00%) A2 - the actual value A3 - the deviation Each cell is formatted for percentages. I have inserted the following formula into A3: =IF(ISBLANK(A2),"",IF(A2<30,"",A2-A1) The formula is supposed to do either of three things: 1. If there is no value in A2, leave A3 blank. 2. If the actual percentage is 30% or lower, leave A3 blank. 3. If the actual percentage is over 30%, calculate the deviation from the standard. However, The fromula is not behaving! No matter what I do, the A3 cel...

email form script to show email adresses of all recipients
I see there is a field in the attributes called torecipients but I cannot add it to the email form. Is there a way I can script this into the email form to show the email addresses of all of the recipients. My idea involved creting a new attribute called all_recipients and adding it to the form then doing a onchange for each of the to, cc, and bcc fields to update all_recipients. SO far it doesnt work. All the field returns is "undefined". Any help is greatly appreciated!!! ...

Problem with import from outlook
Is anyone else having the issue of importing from outlook where it stops working. I am on my 5 rebuild works fine for a while then just breaks. One tile it would crash, i rebuilt then it says the spec is gone, rebuild, then cant even find the folders in outlook they dont even show. I am at my wits end I have multiple database that were built on the fuctionality of the outlook look connector and now this is really starting to effect my business. Tried microsft support but they want 250 bucks for support and I can not afford it. ...

coonection server problem
Everytime I open my outlook 2003, it tells me there was a problem occured during connecting the server, it is a hotmail server and even my private e-mail wont work with this programme, what is wrong , why it does not connect, what must I do to bring it online. I check the antivirus, security, and connection setting and i still can not make it, which drives me insane ,, please if anyone know about it , help me No, you help us first. What error messages are you getting (exact text) and is this a paid Hotmail account or the free one? --� Milly Staples [MVP - Outlook] Post all replies t...

Help! Where do I begin?
I work with over 150 single sheet workbooks created from the same template. I need to take data from 4 or 5 cells on each sheet/workbook and make ONE spreadsheet on which I can sort columns accordingly. I don't know what I need to do. Pivot Table? Macro? Please help. This has been very frustrating as when a customer needs (for example - all engines with 3000-4000 cycles remaining) I have to go to each sheet and look at that cell to find them - which is very time consuming (opening 150 workbooks). Thanks in advance, Darcy Something like this might be what you're looking for (...

Problem including files
Is there a way to display the compile time directives? I'm trying to see what the include paths look like. Thanks Compile-time directives are syntactic entities of the form #include #pragma #if #ifdef #ifndef and the like. None of them involve the include path being displayed. The include path is a combination of the directory settings under tools>Options, Directories tab (in VS6) and the /I: switches established under Project>Settings, C/C++, Preprocessor. The compiler first searches the paths specified by the /I switches, then the paths specified by the directories setting. ...

Script running isinteg -test for all mailbox stores on a server
Hi, Does anybody have a script for: 1. dismounting information stores 2. running isinteg for information store - output to a logfile 3. mounting information store again This would be a nice feature to run once and a while to check that everything is ok! Kind rgds Peter Jensen On Tue, 16 Aug 2005 10:33:17 +0200, "Peter Jensen" <peter.topp@mail.dk> wrote: >Hi, > >Does anybody have a script for: > >1. dismounting information stores >2. running isinteg for information store - output to a logfile >3. mounting information store again > >This would...

Problems with rules
I have a problem with a rule. When I get email from a certain address it ends up in my designated spam folder. The problem is that this particular email address is not listed in my unwanted email list and no rules are supposed to trigger on the message in question. What could be causing this? ...

Outlook And IIS Problems
Hi there, I'm using Windows XP Pro. SP2, IIS 5.1, MS Outlook 2000, SQL Server 2000 Dev. SP4 Internal IP address in LAN environment. I dont have Exchange server. I configure SQL to use system account with my email I configure smtp in IIS with my internal IP Now when I use SQL alert to send mail its does and the email go to mailroot\Queue My question is How to send the email to the mailroot\Mailbox and beable to pick it from Outlook ? What POP and SMTP should be ? Thanks, Oded Dror Email: odeddror@cox.net ...

Problem using a MSR(credit card reader)
Good afternoon so, im implementing RMS 1.3, and have problem with a device. The device is a MSR from MAXPRO; its a keyboard wedge plugged to PS/2 port keyboard (the keyboard ins coneccted to the MSR), the problem is this device dont have OPOS drivers, the company does not exist and i tried to make go on in SO. In notepad, this MSR it works, but in SO when i tender the transaction, i swiping the card but it doesnt write anything in the credit card windows. I tried to active first in MANAGER, but ask me about the OPOS drivers. the MSR MAXPRO it doesnt exist in HCL of RMS. its possilbe make...

Runtime Table Deletes Problem
Hi, I run an Access 2003 system where the reference data and user data are kept in 2 separate DB's, the ref data is updated monthly and issued to the users. The user db is updated with the new ref data by linking tables and then running delete/update queries. I have discovered this method has stopped working for some users lately, the previous months data is left intact, the users don't get an error message of any type, and I can't figure out why. (It also affects certain users when importing data to a temporary table which should be cleared before each new import). It st...

begin
How to be an Excel professional? I saw an accountant created a very nice form sheet before. Don't have a chance to ask. I want to improve now. How to begin? Thanks... Hi LL! Here's a bit of a summary collation of Excel resources posted originally in response to a question on how to become an Excel Expert. Perhaps the very best resource is yourself! Few experts have gained their in-depth knowledge other than by banging their heads on the keyboard trying to work out solutions to problems. It's sometimes frustrating but even blind alleys teach you things and successes are v...

Problem #6
Has anybody ever seen an error message (0x800cccF6) message? I cannot configure my Outlook to retrieve Hotmail. Works with other profiles on this computer running winxp. >-----Original Message----- >Has anybody ever seen an error message (0x800cccF6) message? I cannot >configure my Outlook to retrieve Hotmail. Works with other profiles on this >computer running winxp. >. > Read this: http://www.vnunet.com/news/1158429 ...

Public Folder Replication Problem
Setup Exchange 2000 sp3 EXchange 2003 Many folders are not replicating from old to new server, yet they are all marked to replicate. Also the new servers Exchange System Manager reports folders in sync. The original public store is about 277 Mb while the new public store is only about 57 mb. How can I go about troubleshooting this? Look at the Application Log of the Exchange 2000 server and Exchange 2003 server. I am pretty sure you will see some replication Errors or Warnings. That should be the place to start troubleshooting this issue. -- Mike Manjunath Microsoft Corp. "Plea...

Embedded IE7 browser object
We have an MFC app that embeds the WebBrowser ActiveX control. Starting in IE7, we've been getting a scripting error due to an exception closing a window that the user has already closed for pages that we display in this WebBrowser control. This doesn't happen when the same page is viewed in Internet Explorer 7, nor does it happen in either situation on computers with IE5-6. The following is a JavaScript example that recreates this situation: var winName = "myWin"; var theURL = "http://www.microsoft.com"; var objWin = window.open(theURL, winName); // U...

Problem starting Mac Office 2004
Every time I try to start an Office program, I get the splash screen and then an error message that says the program has encountered a problem and needs to close. If I choose recover my work, I get stuck in a loop. Excel and PowerPoint don't even let me get to the project gallery. Word gets a little further. It actually gives me the project gallery and I get a blank document screen, but before I get a chance to enter anything, it crashes. The latest thing I did was do a custom install of some of the components of Office, equation editor and the templates. How can I uninstall and get a...

Encoding Problem
I have an ASP page that uses CDONTS to send emails, the email is written in Traditional Chinese, and i have set the bodyformat to MIME and body format to HTML. Furthermore, i have set the charset to big5. But the outlook can not display the email in big5 by default, it always used western european (ISO) as default. I would like to ask how can the email display in big5 by default? ...

capture sql logins script
Hello everybody - For disaster recovery purposes we have a secondary gp server on standby. How can I set it up so that the 'caputure sql logins' script will run on my primary gp server and then save the results to the secondary backup gp server? What tool should I use and is there an automatic script I can use? You may approach this in few different ways - 1) Use PSTools to recreate users on the secondary server. This is a free tool and is part of the Professional Services Toools Library. 2) Export out users in a file and run this file using task scheduler and SQL command utility ...

Subform problem 03-18-08
Hi, I've a problem with my subform... When i open the main form i click on the button "New" to start logging data,same time, a form with a timer start working,so when i put the ID that links between the main form and the subform,the subform does not appear because of the timer... Anyone suggest a solution? ...

IMPORT PROBLEM #3
I try to import a file from excel. It imports 9 records and stops. The message is "Map1 Error ox80070057. Try again later" I try again later and get the same results. "dancer" <dancer@microsoft.com> wrote in message news:%23%232QSPOQHHA.3344@TK2MSFTNGP02.phx.gbl... >I try to import a file from excel. It imports 9 records and stops. The >message is "Map1 Error ox80070057. Try again later" > > I try again later and get the same results. > > What is in the file you are trying to import? It is a name and e-mail address. I'...

Script to populate table
Hi all in SQL Server 2008 is there a way to create a script that populate me a table with the data contained in an equal table present in another database?. Thanks a lot Luigi On Wed, 10 Feb 2010 06:31:02 -0800, Luigi <Luigi@discussions.microsoft.com> wrote: > >Hi all >in SQL Server 2008 is there a way to create a script that populate me a >table with the data contained in an equal table present in another database?. > >Thanks a lot > >Luigi insert mytable select * from otherdatabase.dbo.othertable As posted, the poor-man's version...

Submit Button Script
I am having issues with the submit button on my Publisher 2003 form. When I ftp my pub files, after setting the form properties to send the results to my email addy, I get an error 404 page cannot be found. Here is the script it is displaying when I open the edit page function with FP 2003: <form action=--WEBBOT-SELF-- method=POST> <!--webbot bot="SaveResults" s-email-address="info@bohemianhouseproductions.net" s-email-format="TEXT/PRE" b-email-label-fields="TRUE" s-email-Subject="Web Site Form Response" s-builtin-fields...

Problem size of MFC View, with Vista.
When the application expanded to the maximize and the manifest of the application contain : <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> I'm get a View who the right edge go not to the border frame on Vista. Someone has an idea? Since I see nothing in this manfest that has the slightest...

Changing Beginning Page Number
I have a document that begins with page #25. I need to change it to #23, but can't figure out how to do it. Any suggestions? DJ wrote: > I have a document that begins with page #25. I need to > change it to #23, but can't figure out how to do it. Any > suggestions? ==================================== It would be nice to know what program / version you are using but we enjoy guessing so .... Try going to...Insert / Section. -- John Inzer ...

ArraySegnment problem
Hi all I have constructed a custom message encoder for WCF, which works just great. But, now I'm trying to build in encryption which is quite straight forward. The problem is that my encoder works with ArraySegments of bytes. The original segment is a 1024 byte segment with offset 0 and Count = 748 Then I encrypt this resulting in a 1024 byte segment with offset 0 and count =1024 This is send to the server and decrypted to an ArraySegment 100% identical with the original, the only problem is that I now have lost the original count of 748. I have a 1024 byte array...