Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

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 ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 30th, 2004, 04:32 PM
Aries11 Aries11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Aries11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Editing The Registry from an inputbox

Hi everyone!!

Would someone be kind enough to take a look at my script and let me know what it's missing?

Basically, I'm trying to edit a registry value using an input box. When a user types in an account number, I want it to be written to the customernumber value.

Thanks!!

Here's my script...

Dim response
Set WshShell = WScript.CreateObject("WScript.Shell")
response = InputBox("Enter the account number:","Account Box")
if response = "" then
WshShell.RegWrite "HKLM\Software\Teletrac\Fleet Director Client\customernumber", "" ,"REG_DWORD"
End if

Reply With Quote
  #2  
Old August 30th, 2004, 05:06 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
What happens when you run your code? Any errors?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old August 30th, 2004, 05:23 PM
Aries11 Aries11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Aries11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

Hi Doug,


Thanks for the reply. If I run the code 1, I get no error but it never makes the change. But if I include the <> then I get "(7, 15) Microsoft VBScript compilation error: Syntax error."

Code 1

Dim response
Set WshShell = WScript.CreateObject("WScript.Shell")
response = InputBox("Enter the account number:","Account Box")
if response = "" then
WshShell.RegWrite "HKLM\Software\Teletrac\Fleet Director Client\customernumber", "" ,"REG_DWORD"
End if

Code 2

Dim response
Set WshShell = WScript.CreateObject("WScript.Shell")
response = InputBox("Enter the account number:","Account Box")
if response = <>"" then
WshShell.RegWrite "HKLM\Software\Teletrac\Fleet Director Client\customernumber", "" ,"REG_DWORD"
End if

Reply With Quote
  #4  
Old August 30th, 2004, 10:31 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
Try if response <> "" then

Reply With Quote
  #5  
Old August 31st, 2004, 10:26 AM
Aries11 Aries11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Aries11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey Doug. No luck bro!! Here's the error that I got after I tried it.

(9, 1) Microsoft VBScript runtime error: Type mismatch

Reply With Quote
  #6  
Old August 31st, 2004, 10:45 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
I've never used wscript from VB code but if you have the proper project references it should work. Is that the exact error message? Can you post the line of code that causes the error? What version of VB are you using.

Reply With Quote
  #7  
Old August 31st, 2004, 11:39 AM
Aries11 Aries11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Aries11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
I've never used wscript from VB code but if you have the proper project references it should work. Is that the exact error message? Can you post the line of code that causes the error? What version of VB are you using.

Hey Doug,

The version that I am using is 5.6 and attached is the exact error that I am getting. Also, line 9 is this:

WshShell.RegWrite "HKLM\Software\Teletrac\Fleet Director Client\customernumber", "" ,"REG_DWORD"

If I run this line individually, it works.

Thanks
Attached Files
File Type: zip error.zip (10.0 KB, 270 views)

Reply With Quote
  #8  
Old August 31st, 2004, 03:03 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
Maybe using "" as a value for a DWORD is causing the problem? Just a guess.

I assume from what you said you're trying this from a .vbs script file?

It's possible some registry security is preventing your user account from writing to the registry? Another guess.

Reply With Quote
  #9  
Old August 31st, 2004, 03:51 PM
Aries11 Aries11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Aries11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
Maybe using "" as a value for a DWORD is causing the problem? Just a guess.

I assume from what you said you're trying this from a .vbs script file?

It's possible some registry security is preventing your user account from writing to the registry? Another guess.

Hey,

Yes. Also, I have full control over the key. Do you have a better way of doing this?

Reply With Quote
  #10  
Old September 29th, 2004, 04:17 AM
cinchbald cinchbald is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 cinchbald User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am no expert, but try

if not response =

instead of if response <>

Reply With Quote
  #11  
Old September 29th, 2004, 09:19 AM
AnnaChen AnnaChen is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: USA
Posts: 73 AnnaChen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 58 m 29 sec
Reputation Power: 4
Hope your problem had been solved already. If not, please take a look:
Sounds like you didn't catch "response". You said that you run single .RegWrite line without any problem. Why not add something in your condition check?

Like this:
if response = "" then
...
else
...
end if

See if you be able to catch the .regWrite. BYW, the return data type of function InputBox is String. You may use "Trim(response) to clean any space.

Reply With Quote
  #12  
Old October 15th, 2004, 05:52 PM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 4
Hello Aries11,

I believe this should work. You forgot to include the response in RegWrite method.

'---------------------------
Dim response
Set WshShell = WScript.CreateObject("WScript.Shell")
response = InputBox("Enter the account number:","Account Box")
If Trim(response) <> "" Then
WshShell.RegWrite "HKLM\Software\MAI\JamesLe", response, "REG_DWORD"

'WshShell.RegWrite "HKLM\Software\Teletrac\Fleet Director Client\customernumber", response,"REG_DWORD"

End if
'---------------------------

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Editing The Registry from an inputbox


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 5 hosted by Hostway