Manipulating the registry with vbscript 
Author Message
 Manipulating the registry with vbscript

Has anyone successfully manipulated registry values of remote machines over
the network by
reading in machine names from a text file. in my code below I'm trying to
get the var sText to
work with WSHShell.RegDelete. sText contains the machine name which is read
in from a
file then tries to access that registry key of the machine. I did something
similar to this before
in an old scripting langauage. Any help would be appreciated.

' ------------------------------------------------------------------------
' Update News2000 Server services to point to new service name
' ------------------------------------------------------------------------
'
' Write/Delete entries in the registry.

L_Welcome_MsgBox_Message_Text   = "This script demonstrates how to create
and delete registry keys."
L_Welcome_MsgBox_Title_Text     = "Windows Scripting Host Sample"
Call Welcome()

'
****************************************************************************
****
' *
' * Registry related methods.
' *

Dim WSHShell, oFSO, oStream, sText
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oStream = oFSO.OpenTextFile("wrks.dat",1)

Do Until oStream.AtEndOfStream
    sText = oStream.ReadAll
WSHShell.Popup
"HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
NEWS\N2_UBMS\ContentProviderS"
WSHShell.RegDelete
sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
ERATE_NEWS\N2_UBMS\ContentProviderS\"

WSHShell.Popup
"HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
NEWS\N2_UBMS"
WSHShell.RegDelete
sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
ERATE_NEWS\N2_UBMS\"

WSHShell.Popup
"HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
NEWS"
WSHShell.RegDelete
sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
ERATE_NEWS\"

WSHShell.Popup
"HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
R\ 'Top level key'"
WSHShell.RegWrite
sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
ERATE_R\", "Top level key"

WSHShell.Popup
"HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
R\N2_UBMS\ 'Second level key'"
WSHShell.RegWrite
sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
ERATE_R\N2_UBMS\", "Second level key"

Loop

Set oStream = Nothing
Set oREStart = Nothing
Set oREEnd = Nothing

Sub Welcome()
    Dim intDoIt

    intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text,    _
                      vbOKCancel + vbInformation,       _
                      L_Welcome_MsgBox_Title_Text )
    If intDoIt = vbCancel Then
        WScript.Quit
    End If
End Sub



Tue, 02 Sep 2003 07:42:20 GMT  
 Manipulating the registry with vbscript
The WshShell registry methods do not support remote registry access...  There have been quite a few
threads on the same subject over the last week or so.

Search the ...scripting.wsh and ...scripting.VBScript newsgroups for threads with references to
RegObj and/or StdRegProv.

Google Usenet Advanced Search
http://groups.google.com/advanced_group_search

Here's the most recent reply I posted (yesterday in the ...scripting.remote NG where it was a bit
off topic in spite to the NG's name ;-)...

Both the WMI StdRegProv (Standard Registry Provider) and the (Microsoft) RegObj.dll registry
component can access registries on remote boxes (assuming you can Admin access in both cases and
both machines are running WMI 1.5 for StdRegProv)...

'=====
' StdRegProv
' http://msdn.microsoft.com/library/psdk/wmisdk/regprovref_6yie.htm
'=====

set objRegistry = GetObject("winmgmts://" & remotemachine & "/root/default:StdRegProv")

=================================================================
You can get RegObj.dll from:

Visual Basic - Add-Ins, Wizards & Utilities [registered VB owners]
http://msdn.microsoft.com/vbasic/downloads/addon.asp

or

Win32 Scripting [Clarence Washington]
http://cwashington.netreach.net/main_site/downloads

or on the companion CD that comes with "Windows Script Host 2.0 Developer's Guide" from Microsoft
Press.
=================================================================

As of WSH 5.6 beta 1, you can also run scripts remotely.  So a script that accesses the registry
with the WshShell registry methods will access the remote registry when executed on the remote
machine.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Has anyone successfully manipulated registry values of remote machines over
> the network by
> reading in machine names from a text file. in my code below I'm trying to
> get the var sText to
> work with WSHShell.RegDelete. sText contains the machine name which is read
> in from a
> file then tries to access that registry key of the machine. I did something
> similar to this before
> in an old scripting langauage. Any help would be appreciated.

> ' ------------------------------------------------------------------------
> ' Update News2000 Server services to point to new service name
> ' ------------------------------------------------------------------------
> '
> ' Write/Delete entries in the registry.

> L_Welcome_MsgBox_Message_Text   = "This script demonstrates how to create
> and delete registry keys."
> L_Welcome_MsgBox_Title_Text     = "Windows Scripting Host Sample"
> Call Welcome()

> '
> ****************************************************************************
> ****
> ' *
> ' * Registry related methods.
> ' *

> Dim WSHShell, oFSO, oStream, sText
> Set WSHShell = WScript.CreateObject("WScript.Shell")
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oStream = oFSO.OpenTextFile("wrks.dat",1)

> Do Until oStream.AtEndOfStream
>     sText = oStream.ReadAll
> WSHShell.Popup
> "HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
> NEWS\N2_UBMS\ContentProviderS"
> WSHShell.RegDelete
> sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
> ERATE_NEWS\N2_UBMS\ContentProviderS\"

> WSHShell.Popup
> "HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
> NEWS\N2_UBMS"
> WSHShell.RegDelete
> sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
> ERATE_NEWS\N2_UBMS\"

> WSHShell.Popup
> "HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
> NEWS"
> WSHShell.RegDelete
> sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
> ERATE_NEWS\"

> WSHShell.Popup
> "HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
> R\ 'Top level key'"
> WSHShell.RegWrite
> sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
> ERATE_R\", "Top level key"

> WSHShell.Popup
> "HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TELERATE_
> R\N2_UBMS\ 'Second level key'"
> WSHShell.RegWrite
> sText"\HKLM\SOFTWARE\Reuters\NewsServer\AlertProviders\News2000\Services\TEL
> ERATE_R\N2_UBMS\", "Second level key"

> Loop

> Set oStream = Nothing
> Set oREStart = Nothing
> Set oREEnd = Nothing

> Sub Welcome()
>     Dim intDoIt

>     intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text,    _
>                       vbOKCancel + vbInformation,       _
>                       L_Welcome_MsgBox_Title_Text )
>     If intDoIt = vbCancel Then
>         WScript.Quit
>     End If
> End Sub



Tue, 02 Sep 2003 09:50:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Manipulating the registry with vbscript

2. Manipulating the Registry.

3. Manipulating the Registry

4. Manipulating the Registry

5. Manipulate binary files with VBscript

6. How do I manipulate array using VBScript?

7. Manipulating Excel through VBScript problem

8. How do you find objects to manipulate in VBScript

9. Can i manipulate ActiveX control thru VBScript?

10. manipulating databases with VBScript

11. Manipulating Frames in VBScript

12. Manipulating details in explorer windows with vbscript

 

 
Powered by phpBB® Forum Software