c#


How to change the registry value of remote system using C#


Hai every one
I am developing an windows application in which i have to block the removable storage devices such as pendrives.I found that its possible by changing the registry value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor,start value to 4.But the problem is I have to block it on remote systems too.Can any one suggest me how to change the value of registry of remote system using c# with a code or sites where i can i find the code for this.
The .net way is to use Microsoft.Win32.RegistryKey.OpenRemoteBaseKey.
An alternative would be to use WMI. There are lots of examples on Google for reading values; replacing GetStringValue with SetStringValue (or SetDWORDValue, etc.) should do what you want.
You probably want to take a look at the Remote Registry Service and make an RPC call.
MSDN description: http://msdn.microsoft.com/en-us/library/aa940121(WinEmbedded.5).aspx
MSDN example using RegistryKey.OpenRemoteBaseKey: http://msdn.microsoft.com/en-us/library/8zha3xws.aspx
You need to have Remote Registry service running on remote machine. Then you can use WMI to connect the registry. Here is a code sample script from this site:
Dim strComputer
Dim strUserName
Dim strPassword
Dim objLocator
Dim objService
Dim objRegistry
strComputer = "somesys"
strUserName = "somename"
strPassword = "somepw"
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer( strComputer, _
"Root\Default", strUserName, strPassword )
objService.Security_.impersonationlevel = 3
Set objRegistry = objService.Get( "StdRegProv" )
'Do something here like retrieving or setting values.
Set objRegistry = Nothing
Set objLocator = Nothing
Set objService = Nothing
you can get many valuable results by googling for "using WMI to modify remote registry"

Related Links

Error “The remote server returned an error: (400) Bad Request”
XML replace invalid characters with c#
Cannot find elements within a div tag - Selenium
Strange characters reading PDF with iTextSharp
Multiple LeftJoin on same ForeignTable using Linq to Entities
adding class library to web application with net core
C# exchange server get meeting room appointment list
C# capture process network traffic
Synchronously calling async method in WebAPI deadlocks even with ConfigureAwait(false)
Make Visual Studio 2013 Setup Wizard Project to point Net framework 4.0
C# CefSharp enables flash play local mp4 video
How does `Convert.ToBase64String()` work? [closed]
Trying to get a list of “tables” in an excel document
Disable background untill form disspeares [duplicate]
Can constructor initialization be used for dependency injection instead of having DI containers?
List of objects within Class definition

Categories

HOME
macros
leaflet
reference
gaussian
mifare
x86-64
stdout
pyodbc
wkhtmltopdf
core-data
point-of-sale
background-image
game-engine
facebook-marketing-api
powerpivot
openam
printf
fibonacci
functional-dependencies
apdu
core-animation
rancher
angular2-changedetection
resx
akamai
tikz
ibm-bpm
choco
eclipse-jdt
webmock
matlab-compiler
wunderground
headphones
gstreamer-1.0
oracle-bpm-suite
google-chrome-console
autodesk-data-management
smooth-streaming
bootstrap-carousel
taleo
android-doze-and-standby
npoco
spring-data-commons
geminabox
google-cloud-shell
photoshop-script
sharpssh
webmatrix
bipartite
breadcrumbs
directinput
git-push
x12
pyshark
trendline
ooad
methodology
windows-phone-8-emulator
dpkt
vensim
tinymce-plugins
avd
service-broker
react-os
agent-based-modeling
drawable
visual-c#-express-2010
behance-api
pyalgotrade
dateadd
xps
new-operator
class-library
autofilter
code-complete
cab
proj4
bho
nsautoreleasepool
cloudmade
algol
custom-cursor
google-email-audit-api
jquery-ui-map
django-1.4
nserror
parsec
scriptmanager
wdm
pex-and-moles
funambol
nbehave

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App