Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB Script issue with REGEDIT

Posted on 2007-11-14
10
Medium Priority
?
1,023 Views
Last Modified: 2008-02-01
The previous individual that held my position setup AD to use VB scripting for login purposes. All is working well, but I am not familiar with VB programming, and wanted to insert a REGEDIT line that would in effect merge a regkey file for all users. I have read a little about Sh.RegWrite key, but still do not understand how to use it. Here is the REGEDIT script that I am trying to import:

REGEDIT.EXE /s \\servername\sharednamedirectory\filename.reg
(the server & shared directory that the reg file is located in)

I would like to insert a correct entry into our current VB script that will merge this reg key without disrupting the rest of the script process. Hope this is somewhat understandable, but I will be happy to further elaborate.
Thanks for looking...
0
Comment
Question by:graniteit
[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
  • 6
  • 4
10 Comments
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20285006
Here's a little script I found to input all the .reg files in a directory:

'***********************************************************
' EDIT YOUR PREFERENCES BELOW
'***********************************************************
WorkingDir = "C:\PathTo\MyRegFiles"
Extension = ".reg"
ExecCmd = "REGEDIT /S "
'***********************************************************
' DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
'***********************************************************
Dim fso, myFolder, fileColl, aFile

Set fso = CreateObject("Scripting.FileSystemObject")
Set myFolder = fso.GetFolder(WorkingDir)
Set fileColl = myFolder.Files
For Each aFile in fileColl
  ext = right(aFile.name, 4)
  if Ucase(ext) = Ucase(Extension) then
    Set WshShell = WScript.CreateObject("WScript.Shell")
    RetVal = WshShell.Run(ExecCmd & chr(34) & aFile & chr(34), 1, True)
    set WshShell = nothing
  end if
Next

Hope that helps.
0
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20285017
Actually this one is probably better for your case (just one reg file)

strCommand = "regedit /s c:\sample.reg"
set objWshShell = WScript.CreateObject("WScript.Shell")
intRC = objWshShell.Run(strCommand, 0, TRUE)
if intRC <> 0 then
 WScript.Echo "Error returned from importing registry: " & intRC
else
 WScript.Echo "No errors returned from importing the registry file"
end if
0
 

Author Comment

by:graniteit
ID: 20301132
Thanks bayesianmind...one quick, dumb question: would i simply copy over the VB script above, edit the reg file name & import it into the VB login script in AD/GPO?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:bayesianmind
ID: 20306021
Yeah that should work.
0
 

Author Comment

by:graniteit
ID: 20320018
Bayesianmind:

When I copied over the script, I edited only the FQDN of the reg file, then inserted it into the VB login script. Had a user reboot and try logging to see if the process took place and received a VB Script error. Don't have the exact message at this time, but could reproduce if necessry. Not sure if it occurred because of where I placed the entry into the login script...
0
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20321501
Which one did you use? Also when you put in the FQDN did you add any quotes that would mess with the quoting already in place?
0
 

Author Comment

by:graniteit
ID: 20322306
I copied the entire entry you posted line for line, with the only change being the directory that the .reg file is located at...did not modify the quotes around the regedit. Put the entire new entry into the AD/GPO login script after the drive mappings, so that the network drive that the .reg is on would be accessible by the pc.
0
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20329024
Try the second shorter script I posted. Its specifically made for one .reg file.
0
 

Author Comment

by:graniteit
ID: 20344275
bayesianmind:

I actually used the shorter of the two scripts you provided. Just changed the path to the .reg file and inserted it as listed above, after network drive mappings run.
Thanks again...
0
 
LVL 3

Accepted Solution

by:
bayesianmind earned 300 total points
ID: 20344938
Not sure why it doesn't work, does anyone else know?

Give the first one a try, perhaps that one will work. Just make a special directory for it with only the one .reg file you need.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 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