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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btRDesktop.Clic k
Const HKEY_CURRENT_US ER = &H80000001
Const HKEY_LOCAL_MACH INE = &H80000002
Dim myConnectionOpt ions As New System.Manageme nt.ConnectionOp tions
With myConnectionOpt ions
..Impersonation = System.Manageme nt.Impersonatio nLevel.Imperson ate
'* Use next line for XP
..Authenticatio n = System.Manageme nt.Authenticati onLevel.Packet
'* Use next line for Win prior XP
'*.Authenticati on = System.Manageme nt.Authenticati onLevel.Connect
End With
Dim myManagementSco pe As System.Manageme nt.ManagementSc ope
'* Replace the "." with an actual servername for remote connection
Dim myServerName As String = bxInputBox.Text
myManagementSco pe = New System.Manageme nt.ManagementSc ope("\\" & _
myServerName & "\root\cimv2:St dRegProv", myConnectionOpt ions)
'* connect to WMI namespace
myManagementSco pe.Connect()
If myManagementSco pe.IsConnected = False Then
bxOutputBox.App endText("Could not connect to WMI namespace")
End If
Dim myObjectSearche r As System.Manageme nt.ManagementOb jectSearcher
Dim myCollection As System.Manageme nt.ManagementOb jectCollection
Dim myObject As System.Manageme nt.ManagementOb ject
Dim strKeyPath = "SOFTWARE\Micro soft\Windows Script Host\Settings"
Dim strValueName = "TrustPolic y"
'myObjectSearch er = New System.Manageme nt.ManagementOb jectSearcher( _
' myManagementSco pe.Path.ToStrin g, "Select * From Win32_Product")
'myObjectSearch er.Get(HKEY_LOC AL_MACHINE, strKeyPath, strValueName,
strValue)
'bxOutputBox.Ap pendText("Curre nt WSH Trust Policy Value: " & strValue)
End Sub
End Class
=============== =============== =============== =========== 1 1921
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:StdR egProv
change this to
root\default:St dRegProv
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*******@hotm ail.com> wrote in message
news:eD******** ********@tk2msf tngp13.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(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btRDesktop.Clic k Const HKEY_CURRENT_US ER = &H80000001 Const HKEY_LOCAL_MACH INE = &H80000002
Dim myConnectionOpt ions As New System.Manageme nt.ConnectionOp tions With myConnectionOpt ions .Impersonation = System.Manageme nt.Impersonatio nLevel.Imperson ate '* Use next line for XP .Authentication = System.Manageme nt.Authenticati onLevel.Packet '* Use next line for Win prior XP '*.Authenticati on = System.Manageme nt.Authenticati onLevel.Connect End With Dim myManagementSco pe As System.Manageme nt.ManagementSc ope '* Replace the "." with an actual servername for remote connection Dim myServerName As String = bxInputBox.Text myManagementSco pe = New System.Manageme nt.ManagementSc ope("\\" & _ myServerName & "\root\cimv2:St dRegProv", myConnectionOpt ions) '* connect to WMI namespace myManagementSco pe.Connect() If myManagementSco pe.IsConnected = False Then bxOutputBox.App endText("Could not connect to WMI namespace") End If Dim myObjectSearche r As System.Manageme nt.ManagementOb jectSearcher Dim myCollection As System.Manageme nt.ManagementOb jectCollection Dim myObject As System.Manageme nt.ManagementOb ject Dim strKeyPath = "SOFTWARE\Micro soft\Windows Script Host\Settings" Dim strValueName = "TrustPolic y" 'myObjectSearch er = New System.Manageme nt.ManagementOb jectSearcher( _ ' myManagementSco pe.Path.ToStrin g, "Select * From Win32_Product")
'myObjectSearch er.Get(HKEY_LOC AL_MACHINE, strKeyPath, strValueName, strValue) 'bxOutputBox.Ap pendText("Curre nt WSH Trust Policy Value: " & strValue)
End Sub End Class =============== =============== =============== =========== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 server on the network, I'm not able to do the above. Is there something that must be set in order to allow this.
Thanks
|
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 a new Hyperlink to the existing table od hyperlinks ) and
copy it back (overwriting the old copy ) to the remote server.
Thanks, for your time !
|
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
SourceTableName As String
Attributes As Long
IndexSQL As String
End Type
|
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:
1) modify all autoexec macros to add an action to run this procedure
OR
2) designate it to be ran from TOOLS>STARTUP, inserted into a form
Any code examples or suggestions would be appreciated.
|
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 manipulate resident tables using code but not a
remote or attached database.
Any help you could provide would be greatly appreciated
| |
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;
public class LogTest
{
public static void Main(String args)
|
by: Nikolay Petrov |
last post by:
How can I modify remote registry.
Also need to use different credentials.
Thanks
|
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 include
the user name and password in the HTTP header, but I'm not quite sure
how to access the HTTP header that is sent with the webservice soap
message request.
Can anyone help?
|
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. I have a local HTML file, where I have some kind of link. When this
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |