Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use VBS script and WSHShell.RegWrite

Posted on 2004-09-29
4
Medium Priority
?
4,469 Views
Last Modified: 2008-01-09
A small project I am working on requires a silent installation of some software. For NAV2k5, it means no CD Key gets entered. I want a .vbs script I can run that prompts for the CD key, then merges the key to the registry.
This can be done with the info here ( http://www.winguides.com/scripting/library.php?id=6 ).

The key is...
[HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\CCPD-LC\KStore\00000082\00000002\00000002]
"Key"="xxxxxxxxxxxxxxxxxxxxxxxx"

I need the .vbs script to prompt for the "xxxxxxxx"'s
Should be easy enough, I think...I don't know how to do it though. Any takers?
0
Comment
Question by:DVation191
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:avi247
ID: 12181919
Option Explicit

' [HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\CCPD-LC\KStore\00000082\00000002\00000002]
' "Key"="xxxxxxxxxxxxxxxxxxxxxxxx"
' REF:  http://www.winguides.com/scripting/library.php?id=6

Dim CDKEY
Dim WSHShell, RegKey, ScreenSaver, Result


CDKEY = InputBox("CD Key","Please enter the CD Key and press Ok. Press Cancel to Exit.","")

' keep asking till your CDKEY is valid or user exits.
While Not IsCDKeyValid(CDKEY)
  CDKEY = InputBox("CD Key","Please enter a valid CD Key and press Ok.","")
wend


Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\CCPD-LC\KStore\00000082\00000002\00000002\"
WSHShell.RegWrite regkey & "Key", CDKEY
Set WSHShell = Nothing
Msgbox("Done")


Function IsCDKeyValid(CDKEY)

  CDKEY = Trim(CDKEY)  

 'enter validation functions here
  If Len(CDKEY) = 0 Or Len(CDKEY) = 10 then
    IsCDKeyValid = True
  else
    IsCDKeyValid = False
  end if

End Function
0
 
LVL 20

Author Comment

by:DVation191
ID: 12182513
looks good.

i'd do this myself if i could...but could you remove the valid cd key check? it isnt necessary because i want to be able to accept a variety of legit keys, and the application itself will check the validity of the key upon startup.

if you could do that i'd say this question is closed. thanks for your help.
0
 
LVL 4

Accepted Solution

by:
avi247 earned 2000 total points
ID: 12182878
Option Explicit

' [HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\CCPD-LC\KStore\00000082\00000002\00000002]
' "Key"="xxxxxxxxxxxxxxxxxxxxxxxx"

Dim CDKEY
Dim WSHShell, RegKey, ScreenSaver, Result


CDKEY = InputBox("Please enter the CD Key and press Ok. Press Cancel to Exit.","CD Key","")


If CDKEY <> "" then
      Set WSHShell = CreateObject("WScript.Shell")
      RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\CCPD-LC\KStore\00000082\00000002\00000002\"
      WSHShell.RegWrite regkey & "Key", CDKEY
      Set WSHShell = Nothing
end if

0
 
LVL 20

Author Comment

by:DVation191
ID: 12183027
Many thanks. It's perfect!
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question