|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
Try if response <> "" then
|
|
#5
|
|||
|
|||
|
Hey Doug. No luck bro!! Here's the error that I got after I tried it.
(9, 1) Microsoft VBScript runtime error: Type mismatch |
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
Quote:
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 |
|
#8
|
|||
|
|||
|
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. |
|
#9
|
|||
|
|||
|
Quote:
Hey, Yes. Also, I have full control over the key. Do you have a better way of doing this? |
|
#10
|
|||
|
|||
|
I am no expert, but try
if not response = instead of if response <> |
|
#11
|
|||
|
|||
|
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. |
|
#12
|
|||
|
|||
|
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 '--------------------------- |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Editing The Registry from an inputbox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|