Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 12th, 2006, 02:08 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Salem, OH
Posts: 340 Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)  Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Days 11 h 55 m 56 sec
Reputation Power: 50
Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo
WSH Problem

Okay anyone got an explanation?

Code:
regtest.vbs
strRegValue = "HKLM\Software\Microsoft\Windows\CurrentVersion\ProductID"

Set WshShell = WScript.CreateObject("WScript.Shell")

strPID = WshShell.RegRead (strRegValue)
Wscript.Echo strPID

WshShell.RegDelete strRegValue
Wscript.Echo "The registry value has been deleted."

WshShell.RegWrite strRegValue, strPID
Wscript.Echo "The registry value has been written back."


Why am I recieving an error when I use the VBScript syntax for the RegRead method (without parenthesis)? The RegWrite and RegDelete methods both work properly, but the RegRead method won't execute without parenthesis.
__________________
Ask the Windows Guru!

Open me for some very useful links!    

Last edited by nilpo : August 12th, 2006 at 05:37 AM.

Reply With Quote
  #2  
Old August 16th, 2006, 05:06 PM
reclusive1 reclusive1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 2 reclusive1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 4 sec
Reputation Power: 0
Hi Nilpo,

The reason is because the RegWrite and RegDelete routines are Sub routines and are not returning a value.

The RegRead routine is a Function and does return a value.

Vbscript syntax requires that a function always is followed by parenthesis even if no value is passed into the function.

I think this dates to the original coding syntax defined for vbscript.

Reply With Quote
  #3  
Old August 17th, 2006, 02:03 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Salem, OH
Posts: 340 Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)  Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177725 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Days 11 h 55 m 56 sec
Reputation Power: 50
Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo
RegRead IS a function? That's interesting. It does make sense considering it returns the value it finds in the registry. I wasn't aware of that. Thanks for the heads up.

Last edited by nilpo : August 17th, 2006 at 02:05 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > WSH Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway