473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how do I modify remote registeries using VB.NET (and COM+)

I am attempting to write a VB.net program to alter remote registeries. I am
familiar with VBScript and so I was using WMI to connect to remote machines.
How would I do this in VB.Net?

I got this far..

================================================== ====
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btRDesktop.Click
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim myConnectionOptions As New System.Management.ConnectionOptions
With myConnectionOptions
..Impersonation = System.Management.ImpersonationLevel.Impersonate
'* Use next line for XP
..Authentication = System.Management.AuthenticationLevel.Packet
'* Use next line for Win prior XP
'*.Authentication = System.Management.AuthenticationLevel.Connect
End With
Dim myManagementScope As System.Management.ManagementScope
'* Replace the "." with an actual servername for remote connection
Dim myServerName As String = bxInputBox.Text
myManagementScope = New System.Management.ManagementScope("\\" & _
myServerName & "\root\cimv2:StdRegProv", myConnectionOptions)
'* connect to WMI namespace
myManagementScope.Connect()
If myManagementScope.IsConnected = False Then
bxOutputBox.AppendText("Could not connect to WMI namespace")
End If
Dim myObjectSearcher As System.Management.ManagementObjectSearcher
Dim myCollection As System.Management.ManagementObjectCollection
Dim myObject As System.Management.ManagementObject
Dim strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings"
Dim strValueName = "TrustPolicy"
'myObjectSearcher = New System.Management.ManagementObjectSearcher( _
' myManagementScope.Path.ToString, "Select * From Win32_Product")

'myObjectSearcher.Get(HKEY_LOCAL_MACHINE, strKeyPath, strValueName,
strValue)
'bxOutputBox.AppendText("Current WSH Trust Policy Value: " & strValue)

End Sub
End Class
================================================== ======

Nov 21 '05 #1
1 1904
StdRegProv registry Provider class will do the trick for you. However I see
one problem wiht your connect string below

You currently have
root\cimv2:StdRegProv

change this to
root\default:StdRegProv

Please look at the 2nd link below for examples

--
Thanks,
Rajesh

Key WMI Resources:
1> Official WMI FAQ from WMI Development Team:
http://www.microsoft.com/technet/scr...es/wmifaq.mspx
2> Technet Scriptcenter Resource for lots of common system administration
problems:
http://www.microsoft.com/technet/scr...r/default.mspx

"james" <ja*******@hotmail.com> wrote in message
news:eD****************@tk2msftngp13.phx.gbl...
I am attempting to write a VB.net program to alter remote registeries. I am
familiar with VBScript and so I was using WMI to connect to remote
machines.
How would I do this in VB.Net?

I got this far..

================================================== ====
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btRDesktop.Click
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Dim myConnectionOptions As New System.Management.ConnectionOptions
With myConnectionOptions
.Impersonation = System.Management.ImpersonationLevel.Impersonate
'* Use next line for XP
.Authentication = System.Management.AuthenticationLevel.Packet
'* Use next line for Win prior XP
'*.Authentication = System.Management.AuthenticationLevel.Connect
End With
Dim myManagementScope As System.Management.ManagementScope
'* Replace the "." with an actual servername for remote connection
Dim myServerName As String = bxInputBox.Text
myManagementScope = New System.Management.ManagementScope("\\" & _
myServerName & "\root\cimv2:StdRegProv", myConnectionOptions)
'* connect to WMI namespace
myManagementScope.Connect()
If myManagementScope.IsConnected = False Then
bxOutputBox.AppendText("Could not connect to WMI namespace")
End If
Dim myObjectSearcher As System.Management.ManagementObjectSearcher
Dim myCollection As System.Management.ManagementObjectCollection
Dim myObject As System.Management.ManagementObject
Dim strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings"
Dim strValueName = "TrustPolicy"
'myObjectSearcher = New System.Management.ManagementObjectSearcher( _
' myManagementScope.Path.ToString, "Select * From Win32_Product")

'myObjectSearcher.Get(HKEY_LOCAL_MACHINE, strKeyPath, strValueName,
strValue)
'bxOutputBox.AppendText("Current WSH Trust Policy Value: " & strValue)

End Sub
End Class
================================================== ======

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob | last post by:
Hi, In the server explorer in Visual Studio.Net I'm able to design tables, create stored procedures, etc for the SQL 2000 database running locally on my computer. If I add a connection to a remove...
5
by: Swarna | last post by:
Hi all, Can anyone help me with this ? I am using scp in python to copy a html file on remote server, to my local machine. Now, i need to update this html file in my local machine ( by adding...
4
by: John | last post by:
I am using code provided by Mr. Steele that allows for my MDB to dynamically connect to remote SQL server databases. The code works fine as follows: Type TableDetails TableName As String...
2
by: danders70 | last post by:
I have hundreds of Access (2.0,97,2K) databases that I need to insert a sub procedure into, which is to be ran at every startup. Does anybody know of a way to remotely, programmatically either:...
2
by: Jozef | last post by:
I'm using Access XP. I'm trying to create a table, modify a table, create in index, and create a relationship in a remote database in code from the program database. I know how to create and...
5
by: roopeman | last post by:
i want Console write the EventLog message when the source = "Print", code as following : using System; using System.Data; using System.Diagnostics; using System.Text.RegularExpressions;...
2
by: Nikolay Petrov | last post by:
How can I modify remote registry. Also need to use different credentials. Thanks
6
by: utnemisis51 | last post by:
Hi, I'm trying to include some user credentials for accessing a remote webservice. The remote location requires that I use Basic authentication, which means, from browsing around, I need to...
2
by: Martin Mosbęk Christiansen | last post by:
Hi I have been searching this group but I haven't found anything I can use... Is it possible to remote modify an already open window form from a local HTML file? Example (simplified): 1....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.