Hello, and thanks in advance. I have the below code which keeps
returning "1" as the result. It's never successful, and I don't know
what I'm doing wrong. I know that when I get to objManagementClass &
objManagmeentBaseObject, the VB debugger says "can't read value" on all
lines. Bu tI can read the objPath, and the scope just fine.
Dim strStringValue As String = ""
'Dim strValue As String
Dim objManagementScope As ManagementScope
Dim objManagementClass As ManagementClass
Dim objManagementBaseObject As ManagementBaseObject
Dim objPath As ManagementPath
sSubKey = sSubKey.Trim
strValue = strValue.Trim
If (sSubKey.Length > 0) Then
'Connect to the specified computer registry
objPath = New ManagementPath
objPath.Server = "SERVERNAME(WIN2003)"
objPath.NamespacePath = "root\default"
objPath.ClassName = "stdRegProv"
objManagementScope = New ManagementScope(objPath)
objManagementScope.Options.EnablePrivileges = True
objManagementScope.Options.Impersonation =
ImpersonationLevel.Impersonate
objManagementScope.Connect()
'Retrieve the required string value from the registry
If objManagementScope.IsConnected Then
objManagementClass = New ManagementClass(objPath)
objManagementClass.Scope = objManagementScope
objManagementBaseObject =
objManagementClass.GetMethodParameters("GetStringV alue")
objManagementBaseObject.SetPropertyValue("sSubKeyN ame",
sSubKey)
objManagementBaseObject.SetPropertyValue("sValueNa me",
strValue)
objManagementBaseObject =
objManagementClass.InvokeMethod("GetStringValue",
objManagementBaseObject, Nothing)
strReturn =
objManagementBaseObject.Properties.Item("ReturnVal ue").Value.ToString()
If strReturn = "0" Then
strResult =
CType(objManagementBaseObject.Properties.Item("sVa lue").Value, String)
Else
strReturn =
objManagementBaseObject.Properties.Item("ReturnVal ue").Value.ToString
End If
'objManagementclass.
End If
End If 2 1789
BMack,
Andy reason that you don't use the registry class for this? http://msdn.microsoft.com/library/de...classtopic.asp
I hope this helps,
Cor
"Bmack500" <br********@gmail.com> schreef in bericht
news:11**********************@y43g2000cwc.googlegr oups.com... Hello, and thanks in advance. I have the below code which keeps returning "1" as the result. It's never successful, and I don't know what I'm doing wrong. I know that when I get to objManagementClass & objManagmeentBaseObject, the VB debugger says "can't read value" on all lines. Bu tI can read the objPath, and the scope just fine.
Dim strStringValue As String = ""
'Dim strValue As String Dim objManagementScope As ManagementScope Dim objManagementClass As ManagementClass Dim objManagementBaseObject As ManagementBaseObject Dim objPath As ManagementPath
sSubKey = sSubKey.Trim strValue = strValue.Trim
If (sSubKey.Length > 0) Then 'Connect to the specified computer registry objPath = New ManagementPath objPath.Server = "SERVERNAME(WIN2003)" objPath.NamespacePath = "root\default" objPath.ClassName = "stdRegProv"
objManagementScope = New ManagementScope(objPath) objManagementScope.Options.EnablePrivileges = True objManagementScope.Options.Impersonation = ImpersonationLevel.Impersonate objManagementScope.Connect()
'Retrieve the required string value from the registry
If objManagementScope.IsConnected Then objManagementClass = New ManagementClass(objPath) objManagementClass.Scope = objManagementScope objManagementBaseObject = objManagementClass.GetMethodParameters("GetStringV alue") objManagementBaseObject.SetPropertyValue("sSubKeyN ame", sSubKey) objManagementBaseObject.SetPropertyValue("sValueNa me", strValue) objManagementBaseObject = objManagementClass.InvokeMethod("GetStringValue", objManagementBaseObject, Nothing) strReturn = objManagementBaseObject.Properties.Item("ReturnVal ue").Value.ToString() If strReturn = "0" Then strResult = CType(objManagementBaseObject.Properties.Item("sVa lue").Value, String) Else strReturn = objManagementBaseObject.Properties.Item("ReturnVal ue").Value.ToString End If 'objManagementclass. End If End If This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Yitzhak |
last post by:
I am having "Permission denied" error while calling
LogEvent method of WScript.Shell component.
Basically, ASP page calls Windows Script Host Shell
component to log events to the OS Application...
|
by: dinesh prasad |
last post by:
I'm trying to use a servlet to process a form, then send that data to
an SQL server stored procedure. I'm using the WebLogic 8 App. server.
I am able to retrieve database information, so I know my...
|
by: Steve |
last post by:
Hello --
I've been struggling with this problem for over a day now. I'd like to
know (without passing parameters) which class, and preferably, which
method of that class has called my function....
|
by: tshad |
last post by:
I thought I understood how the SaveViewState is working and was trying to
use this (as per some code I found) to detect refreshes. It seemed to be
working but I found that the SaveViewState was...
|
by: lukecooley |
last post by:
I am new to coding in vb.net and I am trying to add a registry value in
the runonce key. The key is added correctly, as I can see it when
going directly into the registry after executing my code,...
|
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= |
last post by:
I am executing an AJAX page method that is a long running task. After
starting the first method, I execute a second page method to retrieve the
status of the task. It works fine in an empty web...
|
by: Kerem Gümrükcü |
last post by:
Hi,
the topic of this thread implies the question.
Why does this happen. What can i do against
it. App runs in admin context, then ii switch to
user standard user context and open a form
with...
|
by: mark |
last post by:
I am writing a program that will be placed in the startup folder so
that on login it executes, it also needs to delete itself so it
creates a batch file which cleans up. After that it restarts the...
|
by: Frinavale |
last post by:
This has to be one of the most frustrating controls I've ever designed.
First I couldn't stop the __doPostback method from executing for DropDownLists (ie select elements).
Now the __doPostback...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |