473,320 Members | 1,887 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,320 software developers and data experts.

Code Sample To Change Remote Registry Key

hi all,

I thought I would give this back and see if anyone could improve on it. I
was working with the remote registry class. This code opens the
ScreenSaverIsSecure registry setting and changes it to not require a
password prompt anymore.

One change that would be helpful is to somehow figure out how to include an
IP address where the server name is called. I suspect it is a syntax I am
missing. This morning I was running it from within teh network from other
machines so I could get away with it.

Imports System.Management
Imports System
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Security.Permissions
Imports Microsoft.Win32

Dim options As ConnectionOptions
options = New ConnectionOptions()
options.Impersonation = ImpersonationLevel.Impersonate
options.Username = "username"
options.Password = "password"

Dim scope As ManagementScope

scope = New ManagementScope("\\servername\root\cimv2", options)
scope.Options.EnablePrivileges = True
scope.Connect()
If scope.IsConnected = True Then
MsgBox("CONNECTED")
End If

Try
Dim environmentKey As RegistryKey
environmentKey = RegistryKey.OpenRemoteBaseKey( _
RegistryHive.CurrentUser,
"SERVERNAME").OpenSubKey("Control Panel\Desktop", True)

For Each valueName As String In
environmentKey.GetValueNames()
If valueName.ToString = "ScreenSaverIsSecure" Then
environmentKey.SetValue(valueName, "1")
Exit For
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Jan 9 '06 #1
2 12655
One interesting result of this code was that no computer that was a member
of the domain would be allowed to reboot the server. Contstantly drew
security exceptions concerning the changing of the value in the registry on
the server. It did permit it to login.

However, machines not members of the domain but using the same connection on
the network were able to execute this code and reboot the server.

Again if anyone knows how to adjus the servername so that in can include an
IP address please advise.

Kelly
"scorpion53061" <sc************@nospamhereyahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
hi all,

I thought I would give this back and see if anyone could improve on it. I
was working with the remote registry class. This code opens the
ScreenSaverIsSecure registry setting and changes it to not require a
password prompt anymore.

One change that would be helpful is to somehow figure out how to include
an IP address where the server name is called. I suspect it is a syntax I
am missing. This morning I was running it from within teh network from
other machines so I could get away with it.

Imports System.Management
Imports System
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Security.Permissions
Imports Microsoft.Win32

Dim options As ConnectionOptions
options = New ConnectionOptions()
options.Impersonation = ImpersonationLevel.Impersonate
options.Username = "username"
options.Password = "password"

Dim scope As ManagementScope

scope = New ManagementScope("\\servername\root\cimv2", options)
scope.Options.EnablePrivileges = True
scope.Connect()
If scope.IsConnected = True Then
MsgBox("CONNECTED")
End If

Try
Dim environmentKey As RegistryKey
environmentKey = RegistryKey.OpenRemoteBaseKey( _
RegistryHive.CurrentUser,
"SERVERNAME").OpenSubKey("Control Panel\Desktop", True)

For Each valueName As String In
environmentKey.GetValueNames()
If valueName.ToString = "ScreenSaverIsSecure" Then
environmentKey.SetValue(valueName, "1")
Exit For
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try

Jan 10 '06 #2
The way to include an IP address when using WMI and requesting a connection
to the server is like this:

Dim scope As ManagementScope
scope = New ManagementScope("\\10.100.10.10\root\cimv2",
options)

Port 135 must be open and MSDTC must be enabled on the server. For those
reasons it I will only use this on a short term basis.

It does not appear to be possible however to run this application from a
member of the domain's computer regardless of how I impersonate the
Administrator. Again if anyone has ideas on how to make this happen I would
like to hear it.

If it runs from an outside machine where the user is the Administrator it
will reboot the system while using the public IP to connect. Otherwise if
you attempt this from a machine that is a member of the server's domain, it
will give you security exceptions about being not allowed to access the
registry.

This is my last post as no one else seems interested in this topic. It
obviously is timely for me.

Kelly

"scorpion53061" <sc************@nospamhereyahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
hi all,

I thought I would give this back and see if anyone could improve on it. I
was working with the remote registry class. This code opens the
ScreenSaverIsSecure registry setting and changes it to not require a
password prompt anymore.

One change that would be helpful is to somehow figure out how to include
an IP address where the server name is called. I suspect it is a syntax I
am missing. This morning I was running it from within teh network from
other machines so I could get away with it.

Imports System.Management
Imports System
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Security.Permissions
Imports Microsoft.Win32

Dim options As ConnectionOptions
options = New ConnectionOptions()
options.Impersonation = ImpersonationLevel.Impersonate
options.Username = "username"
options.Password = "password"

Dim scope As ManagementScope

scope = New ManagementScope("\\servername\root\cimv2", options)
scope.Options.EnablePrivileges = True
scope.Connect()
If scope.IsConnected = True Then
MsgBox("CONNECTED")
End If

Try
Dim environmentKey As RegistryKey
environmentKey = RegistryKey.OpenRemoteBaseKey( _
RegistryHive.CurrentUser,
"SERVERNAME").OpenSubKey("Control Panel\Desktop", True)

For Each valueName As String In
environmentKey.GetValueNames()
If valueName.ToString = "ScreenSaverIsSecure" Then
environmentKey.SetValue(valueName, "1")
Exit For
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try

Jan 11 '06 #3

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

Similar topics

15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: scorpion53061 | last post by:
Trying to change a value named in a remote registry. In this case we want to set the password protect function of the screensaver so WMI can do a reboot of the system. (IsSecure or...
16
by: gumby | last post by:
I'm having trouble getting HADR to work with the sample databases on two HS20 xSeries blades, Red Hat ES4 up3, DB2 8.2.4, getting the following error. SQL1768N Unable to start HADR. Reason code...
4
by: Chuck B | last post by:
I am modifying remote registries for about 150 computers. Is there any easy way in C# to do a remote registry backup?
3
by: CAIBird | last post by:
hi, i'm wondering how to reader or write registry of a remote host. are there any classes help? Thanks in advance -Zhilin
7
by: Mark Carrington | last post by:
I'm developing a web app in .NET 2 using C#, and occasionally see this error, apparently something to do with the theme used on the site: Compiler Error Message: The compiler failed with error...
3
by: JB | last post by:
I am trying to access a registry key on computer like so: key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(Subkey); There are two keys I am trying to...
8
by: Hayato Iriumi | last post by:
Hello, folks. I have a need to get the value of %windir% on a remote machine. Is it possible to get this value using C#?
6
tlhintoq
by: tlhintoq | last post by:
I pride myself on being able to Google just about anything but... I have fought, tried, searched and fought some more on this one. I am using VMware, and am able to debug from Visual Studio to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.