本文整理汇总了C#中System.Management.ObjectGetOptions类的典型用法代码示例。如果您正苦于以下问题:C# ObjectGetOptions类的具体用法?C# ObjectGetOptions怎么用?C# ObjectGetOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectGetOptions类属于System.Management命名空间,在下文中一共展示了ObjectGetOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: buttonSystemRestore_Click
//Create a system restore point using WMI. Should work in XP, VIsta and 7
private void buttonSystemRestore_Click(object sender, EventArgs e)
{
ManagementScope oScope = new ManagementScope("\\\\localhost\\root\\default");
ManagementPath oPath = new ManagementPath("SystemRestore");
ObjectGetOptions oGetOp = new ObjectGetOptions();
ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);
ManagementBaseObject oInParams = oProcess.GetMethodParameters("CreateRestorePoint");
oInParams["Description"] = "Nvidia PowerMizer Manager";
oInParams["RestorePointType"] = 10;
oInParams["EventType"] = 100;
this.buttonOK.Enabled = false;
this.buttonCancel.Enabled = false;
this.buttonSystemRestore.Enabled = false;
this.labelDis.Text = "Creating System Restore Point. Please wait...";
ManagementBaseObject oOutParams = oProcess.InvokeMethod("CreateRestorePoint", oInParams, null);
this.buttonOK.Enabled = true;
this.buttonCancel.Enabled = true;
this.buttonSystemRestore.Enabled = true;
this.labelDis.Text = text;
}
开发者ID:michael-manley,项目名称:nvpmmgr,代码行数:27,代码来源:InstantApplyDisc.cs
示例2: getComputerInfos
public static String[] getComputerInfos(string computername)
{
String[] computerInfos = new String[2];
ConnectionOptions connOptions = new ConnectionOptions();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
//To use caller credential
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", computername), connOptions);
manScope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(manScope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection){
computerInfos[0] = Convert.ToString(m["Caption"]);
computerInfos[1] = Convert.ToString(m["Status"]);
}
return computerInfos;
}
开发者ID:banctilrobitaille,项目名称:RemoteScriptLauncher,代码行数:26,代码来源:CommUtility.cs
示例3: InstallHosts
public static string InstallHosts(string ServerName, string HostName, string UserName, string Password, bool StartHost)
{
PutOptions options = new PutOptions();
options.Type = PutType.CreateOnly;
ObjectGetOptions bts_objOptions = new ObjectGetOptions();
// Creating instance of BizTalk Host.
ManagementClass bts_AdminObjClassServerHost = new ManagementClass("root\\MicrosoftBizTalkServer", "MSBTS_ServerHost", bts_objOptions);
ManagementObject bts_AdminObjectServerHost = bts_AdminObjClassServerHost.CreateInstance();
// Make sure to put correct Server Name,username and // password
bts_AdminObjectServerHost["ServerName"] = ServerName;
bts_AdminObjectServerHost["HostName"] = HostName;
bts_AdminObjectServerHost.InvokeMethod("Map", null);
ManagementClass bts_AdminObjClassHostInstance = new ManagementClass("root\\MicrosoftBizTalkServer", "MSBTS_HostInstance", bts_objOptions);
ManagementObject bts_AdminObjectHostInstance = bts_AdminObjClassHostInstance.CreateInstance();
bts_AdminObjectHostInstance["Name"] = "Microsoft BizTalk Server " + HostName + " " + ServerName;
//Also provide correct user name and password.
ManagementBaseObject inParams = bts_AdminObjectHostInstance.GetMethodParameters("Install");
inParams["GrantLogOnAsService"] = false;
inParams["Logon"] = UserName;
inParams["Password"] = Password;
bts_AdminObjectHostInstance.InvokeMethod("Install", inParams, null);
if(StartHost)
bts_AdminObjectHostInstance.InvokeMethod("Start", null);
return " Host - " + HostName + " - has been installed. \r\n";
}
开发者ID:navkar,项目名称:BizTalkControlCenter,代码行数:33,代码来源:WMIMethods.cs
示例4: RemoteComputerInfo
private List<String> RemoteComputerInfo(string Username, string Password, string IP, string sWin32class)
{
List<String> resultList = new List<String>();
ConnectionOptions options = new ConnectionOptions();
options.Username = Username;
options.Password = Password;
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
try
{
ManagementScope mgtScope = new ManagementScope(string.Format("\\\\{0}\\root\\cimv2", IP), options);
mgtScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath mgtPath = new ManagementPath(sWin32class);
ManagementClass mgtClass = new ManagementClass(mgtScope, mgtPath, objectGetOptions);
PropertyDataCollection prptyDataCollection = mgtClass.Properties;
foreach (ManagementObject mgtObject in mgtClass.GetInstances())
{
foreach (PropertyData property in prptyDataCollection)
{
try
{
string mobjvalue = "";
if (mgtObject.Properties[property.Name].Value == null)
{
mobjvalue = "null";
}
else
{
mobjvalue = mgtObject.Properties[property.Name].Value.ToString();
}
if (ShouldInclude(property.Name))
{
resultList.Add(string.Format(property.Name + ": " + mobjvalue));
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
}
}
catch (Exception ex)
{
resultList.Add(string.Format("Can't Connect to Server: {0}\n{1}", IP, ex.Message));
}
return resultList;
}
开发者ID:PaulWillis,项目名称:ServerInfoWMI,代码行数:55,代码来源:SystemInformation.cs
示例5: Main
public static void Main(string[] args)
{
var now = DateTime.Now.ToString();
var filepath = Environment.CurrentDirectory + @"\output.txt";
Console.WriteLine("Fetching information about BitLocker using WIM ..\r\n");
using (var file = File.CreateText(filepath))
{
try
{
var path = new ManagementPath();
path.NamespacePath = BITLOCKER_NS;
path.ClassName = BITLOCKER_CLASS;
var scope = new ManagementScope(path);
var options = new ObjectGetOptions();
var management = new ManagementClass(scope, path, options);
file.WriteLine(string.Format("{0}\r\n", now));
int counter = 1;
foreach (var instance in management.GetInstances())
{
var builder = new StringBuilder();
builder.AppendFormat("{0}.\r\n", counter);
builder.AppendFormat(" DeviceID: {0}\r\n", instance["DeviceID"]);
builder.AppendFormat(" PersistentVolumeID: {0}\r\n", instance["PersistentVolumeID"]);
builder.AppendFormat(" DriveLetter: {0}\r\n", instance["DriveLetter"]);
builder.AppendFormat(" ProtectionStatus: {0}\r\n", instance["ProtectionStatus"]);
Console.WriteLine(builder.ToString());
file.Write(builder.ToString());
counter++;
}
file.Flush();
Console.WriteLine("Output written to: " + filepath);
}
catch (Exception ex)
{
file.WriteLine(ex.Message);
Console.WriteLine(ex.Message);
file.WriteLine(ex.StackTrace);
Console.WriteLine(ex.StackTrace);
}
finally
{
Console.WriteLine("\r\nPress Enter to continue ..");
Console.ReadLine();
}
}
}
开发者ID:JakobssonAndre,项目名称:BitlockedDriveStatus,代码行数:50,代码来源:Program.cs
示例6: QueryConditionForm
//-------------------------------------------------------------------------
// Initializes the EventQueryCondition object, to create a pointer
// back to the parent WMIScripter form.
//-------------------------------------------------------------------------
public QueryConditionForm(QueryControl2 parent)
{
InitializeComponent();
this.StoredValue = "";
this.OperatorBox.Items.Add("=");
this.OperatorBox.Items.Add("<>");
this.OperatorBox.Items.Add(">");
this.OperatorBox.Items.Add("<");
this.OperatorBox.Items.Add("ISA");
this.Q_Info = parent;
this.PropertyList.DrawMode = DrawMode.OwnerDrawFixed;
this.PropertyList.DrawItem += new DrawItemEventHandler(this.PropertyList_DrawItem);
this.ValueList.DrawMode = DrawMode.OwnerDrawFixed;
this.ValueList.DrawItem += new DrawItemEventHandler(this.ValueList_DrawItem);
try
{
ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementClass mc = new ManagementClass(this.Q_Info.GetNamespaceName(),
this.Q_Info.GetClassName(), op);
mc.Options.UseAmendedQualifiers = true;
foreach (PropertyData property in mc.Properties)
{
if (property.IsArray)
{
// Don't add it to the list.
}
else
{
this.PropertyList.Items.Add(property.Name);
}
}
if (this.PropertyList.Items.Count > 0)
{
this.PropertyList.Text = this.PropertyList.Items[0].ToString();
}
}
catch (ManagementException)
{
// Invalid Query, the class or namespace might be blank. Do nothing.
}
}
开发者ID:ctscoville,项目名称:WMIScripter,代码行数:53,代码来源:QueryConditionForm.cs
示例7: TestCreate
private void TestCreate()
{
ConnectionOptions Conn = new ConnectionOptions();
//Conn.Username = "wmitest";
//Conn.Password = "wmitest";
Conn.Impersonation = ImpersonationLevel.Impersonate;
Conn.EnablePrivileges = true;
ManagementScope ms = new ManagementScope(@"\\.\root\sbs", Conn);
ms.Connect();
ObjectGetOptions option = new ObjectGetOptions();
ManagementClass mc = new ManagementClass(ms, new ManagementPath("sbs_user"), option);
ManagementObject mo = mc.CreateInstance();
mo["UserName"] = "aaa";
mo.Put();
}
开发者ID:cpm2710,项目名称:cellbank,代码行数:15,代码来源:Client.cs
示例8: getProfile
/*
*Method that execute a WMI command on a remote computer and return all the profile folders' name
* in an arraylist
*/
public static ArrayList getProfile(string computername)
{
//List to store the user profiles
ArrayList profileList = new ArrayList();
//Line of the file written on the client
string line;
ConnectionOptions connOptions = new ConnectionOptions();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
//To use caller credential
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", computername), connOptions);
manScope.Connect();
InvokeMethodOptions methodOptions = new InvokeMethodOptions(null, System.TimeSpan.MaxValue);
ManagementClass processClass = new ManagementClass(manScope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
//The command to execute to get the profile folder and write the result to C:\\tmp.txt
inParams["CommandLine"] = "cmd /c " + "dir C:\\Users /B" + " > c:\\tmp.txt";
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams,methodOptions);
//Arbitratry delay to make sure that the command is done
Thread.Sleep(2000);
//Reading the result file
StreamReader sr = new StreamReader("\\\\" + computername + "\\c$\\tmp.txt");
line = sr.ReadLine();
//While there are profile
while (line != null)
{
//Add the profile to the arraylist
profileList.Add(line);
line = sr.ReadLine();
}
sr.Close();
return profileList;
}
开发者ID:banctilrobitaille,项目名称:RemoteScriptLauncher,代码行数:49,代码来源:CommUtility.cs
示例9: RemoteHelper
const int delayInAutoEventTimeout = 400; // 400 milliseconds
internal RemoteHelper(string machineName)
{
this.machineName = machineName;
// establish connection
ConnectionOptions co = new ConnectionOptions();
co.Authentication = AuthenticationLevel.PacketPrivacy;
co.Impersonation = ImpersonationLevel.Impersonate;
// define the management scope
managementScope = new ManagementScope("\\\\" + machineName + "\\root\\cimv2", co);
// define the path used
ManagementPath path = new ManagementPath("Win32_Process");
ObjectGetOptions options = new ObjectGetOptions(new ManagementNamedValueCollection(), TimeSpan.FromSeconds(15), false);
// get the object for the defined path in the defined scope
// this object will be the object on which the InvokeMethod will be called
processClass = new ManagementClass(managementScope, path, options);
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:21,代码来源:RemoteHelper.cs
示例10: CreateClientAgents
/// <summary>
/// create client agents on nodes and start agents using WMI
/// </summary>
public static void CreateClientAgents()
{
Parallel.ForEach(TestEngine.TestPackage.Nodes.NodeList, node =>
{
for (int i = 0; i < TestEngine.TestPackage.Nodes.NoOfClientsPerNode; i++)
{
string clientNumber = i.ToString();
//copy exe and other files to client location and start the exe
string remoteServerName = node;
if (!Directory.Exists(@"\\" + remoteServerName + @"\C$\WCFLoadUI" + clientNumber))
{
Directory.CreateDirectory(@"\\" + remoteServerName + @"\C$\WCFLoadUI" + clientNumber);
}
foreach (string newPath in Directory.GetFiles(Environment.CurrentDirectory + @"\WCFService", "*.*",
SearchOption.AllDirectories))
File.Copy(newPath,
newPath.Replace(Environment.CurrentDirectory + @"\WCFService",
@"\\" + remoteServerName + @"\C$\WCFLoadUI" + clientNumber), true);
ConnectionOptions connectionOptions = new ConnectionOptions();
ManagementScope scope =
new ManagementScope(
@"\\" + remoteServerName + "." + Domain.GetComputerDomain().Name + @"\root\CIMV2",
connectionOptions);
scope.Connect();
ManagementPath p = new ManagementPath("Win32_Process");
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementClass classInstance = new ManagementClass(scope, p, objectGetOptions);
ManagementBaseObject inParams = classInstance.GetMethodParameters("Create");
inParams["CommandLine"] = @"C:\WCFLoadUI" + clientNumber + @"\WCFService.exe " + Environment.MachineName + " 9090";
inParams["CurrentDirectory"] = @"C:\WCFLoadUI" + clientNumber;
classInstance.InvokeMethod("Create", inParams, null);
}
});
}
开发者ID:huoxudong125,项目名称:WCFLoadUI,代码行数:44,代码来源:WMI.cs
示例11: Main
static void Main(string[] args)
{
try
{
string ComputerName = "localhost";
ManagementScope Scope;
if (!ComputerName.Equals("localhost", StringComparison.OrdinalIgnoreCase))
{
ConnectionOptions Conn = new ConnectionOptions();
Conn.Username = "";
Conn.Password = "";
Conn.Authority = "ntlmdomain:DOMAIN";
Scope = new ManagementScope(String.Format("\\\\{0}\\[WMINAMESPACE]", ComputerName), Conn);
}
else
Scope = new ManagementScope(String.Format("\\\\{0}\\[WMINAMESPACE]", ComputerName), null);
Scope.Connect();
ObjectGetOptions Options = new ObjectGetOptions();
ManagementPath Path = new ManagementPath("[WMIPATH]");
ManagementObject ClassInstance= new ManagementObject(Scope, Path, Options);
ManagementBaseObject inParams = ClassInstance.GetMethodParameters("[WMIMETHOD]");
开发者ID:bgarrels,项目名称:wmi-delphi-code-creator,代码行数:23,代码来源:TemplateNonStaticMethodInvokerCSharp.cs
示例12: _Clone
internal static ObjectGetOptions _Clone(ObjectGetOptions options, IdentifierChangedEventHandler handler)
{
ObjectGetOptions objectGetOption;
if (options == null)
{
objectGetOption = new ObjectGetOptions();
}
else
{
objectGetOption = new ObjectGetOptions(options.context, options.timeout, options.UseAmendedQualifiers);
}
if (handler == null)
{
if (options != null)
{
objectGetOption.IdentifierChanged += new IdentifierChangedEventHandler(options.HandleIdentifierChange);
}
}
else
{
objectGetOption.IdentifierChanged += handler;
}
return objectGetOption;
}
开发者ID:nickchal,项目名称:pash,代码行数:24,代码来源:ObjectGetOptions.cs
示例13: GroupMembers
public static DataTable GroupMembers(string srv, string usr, string pwd)
{
StringBuilder result = new StringBuilder();
try
{
//
MPSfwk.Model.Server s = new MPSfwk.Model.Server();
s.IPHOST = srv;
s.USUARIO = usr;
s.SENHA = pwd;
ManagementScope ms = scopeMgmt(false, s);
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
//
string targethost = "";
string groupname = "";
string aux_qry = "";
if ((srv.IndexOf(".") == -1) && (srv.ToUpper() != "LOCALHOST"))
{ aux_qry = "select * from Win32_Group Where Domain = '" + srv + "'"; }
else
{ aux_qry = "select * from Win32_Group Where LocalAccount = True"; }
//
//MPS teste - 10/out
//
Console.WriteLine("DEBUG - aux_qry = " + aux_qry);
//
DataTable dt_aux = dtlistaClasse("Win32_Group",
aux_qry,
srv,
usr,
pwd);
//
//Cria tabela para preencher os campos
DataTable dt1 = new DataTable();
dt1.TableName = "GroupMembers";
dt1.Columns.Add("Domain");
dt1.Columns.Add("Group Name");
dt1.Columns.Add("Users");
//
foreach (DataRow drow in dt_aux.Rows)
{
//
DataRow dr = dt1.NewRow();
//
targethost = drow["Domain"].ToString();
groupname = drow["Name"].ToString();
StringBuilder qs = new StringBuilder();
qs.Append("SELECT PartComponent FROM Win32_GroupUser WHERE GroupComponent = \"Win32_Group.Domain='");
qs.Append(targethost);
qs.Append("',Name='");
qs.Append(groupname);
qs.AppendLine("'\"");
ObjectQuery query = new ObjectQuery(qs.ToString());
ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
ManagementPath path = new ManagementPath(m["PartComponent"].ToString());
{
String[] names = path.RelativePath.Split(',');
result.Append(names[0].Substring(names[0].IndexOf("=") + 1).Replace("\"", " ").Trim() + "\\");
result.AppendLine(names[1].Substring(names[1].IndexOf("=") + 1).Replace("\"", " ").Trim() + " ; ");
}
}
//Console.WriteLine("Domain = " + targethost + " Name = " + groupname + " Users = " + result.ToString());
dr["Domain"] = targethost;
dr["Group Name"] = groupname;
dr["Users"] = result.ToString();
dt1.Rows.Add(dr);
//
result = new StringBuilder();
}
return dt1;
//
}
catch (Exception e)
{
Console.WriteLine("|!| GroupMembers Error - " + e.Message);
return null;
}
}
开发者ID:marcos-soares-bnu,项目名称:dotNETWrk,代码行数:82,代码来源:WMI.cs
示例14: ClassList_DrawItem
/// <summary>
/// Handles the event to draw the contents of the class list combo box items.
/// </summary>
private void ClassList_DrawItem(object sender, DrawItemEventArgs e)
{
string text = this.ClassList.GetItemText(this.ClassList.Items[e.Index]);
try
{
ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementClass mc = new ManagementClass(this.NamespaceList.Text,
this.ClassList.GetItemText(this.ClassList.Items[e.Index]), op);
mc.Options.UseAmendedQualifiers = true;
foreach (QualifierData qualifierObject in
mc.Qualifiers)
{
// Gets the class description.
if (qualifierObject.Name.ToLower().Equals("description"))
{
if (qualifierObject.Value.ToString() != String.Empty)
{
text = text + Environment.NewLine;
int length = 0;
foreach (string word in qualifierObject.Value.ToString().Split(" ".ToCharArray()))
{
if (length < 70)
{
text = text + word + " ";
length = length + word.Length;
}
else
{
length = 0;
text = text + word + Environment.NewLine;
}
}
}
}
}
}
catch (ManagementException)
{
}
e.DrawBackground();
using (SolidBrush br = new SolidBrush(e.ForeColor))
{
e.Graphics.DrawString(text, e.Font, br, e.Bounds);
}
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
int x = e.Bounds.Right;
int y = this.ClassList.PointToClient(Cursor.Position).Y - e.Bounds.Height;
this.QueryControlToolTip.Show(text, this.ClassList, x, y);
}
else
{
this.QueryControlToolTip.Hide(this.ClassList);
}
e.DrawFocusRectangle();
}
开发者ID:ctscoville,项目名称:WMIScripter,代码行数:68,代码来源:QueryControl2.cs
示例15: PropertyList_MouseMove
/// <summary>
/// Sets the tool tip for items in the property list.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PropertyList_MouseMove(object sender, MouseEventArgs e)
{
string text = "";
int index = this.PropertyList.IndexFromPoint(e.Location);
if (index >= 0 && index < this.PropertyList.Items.Count)
{
text = this.PropertyList.Items[index].ToString();
try
{
ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementClass mc = new ManagementClass(this.NamespaceList.Text,
this.ClassList.GetItemText(this.ClassList.Text), op);
mc.Options.UseAmendedQualifiers = true;
foreach (QualifierData qualifierObject in
mc.Properties[text].Qualifiers)
{
// Gets the class description.
if (qualifierObject.Name.ToLower().Equals("description"))
{
if (qualifierObject.Value.ToString() != String.Empty)
{
text = text + Environment.NewLine;
int length = 0;
foreach (string word in qualifierObject.Value.ToString().Split(" ".ToCharArray()))
{
if (length < 70)
{
text = text + word + " ";
length = length + word.Length;
}
else
{
length = 0;
text = text + word + Environment.NewLine;
}
}
}
}
}
}
catch (ManagementException)
{
}
if (QueryControlToolTip.GetToolTip(this.PropertyList) != text)
{
this.QueryControlToolTip.SetToolTip(this.PropertyList, text);
}
}
else
{
this.QueryControlToolTip.Hide(this.PropertyList);
}
}
开发者ID:ctscoville,项目名称:WMIScripter,代码行数:65,代码来源:QueryControl2.cs
示例16: CreateRemoteValue
/// <summary>
/// 在远程目标机器上创建一个注册表键值
/// </summary>
/// <param name="connectionScope">ManagementScope</param>
/// <param name="machineName">目标机器IP</param>
/// <param name="BaseKey">注册表分支名</param>
/// <param name="key">主键名称</param>
/// <param name="valueName">键值名称</param>
/// <param name="value">键值</param>
/// <returns>创建成功则返回0</returns>
public static int CreateRemoteValue(ManagementScope connectionScope,
string machineName,
RootKey BaseKey,
string key,
string valueName,
string value)
{
try
{
ObjectGetOptions objectGetOptions = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
connectionScope.Path = new ManagementPath(@"\\" + machineName + @"\root\DEFAULT:StdRegProv");
connectionScope.Connect();
ManagementClass registryTask = new ManagementClass(connectionScope,
new ManagementPath(@"DEFAULT:StdRegProv"), objectGetOptions);
ManagementBaseObject methodParams = registryTask.GetMethodParameters("SetStringValue");
methodParams["hDefKey"] = BaseKey;
methodParams["sSubKeyName"] = key;
methodParams["sValue"] = value;
methodParams["sValueName"] = valueName;
ManagementBaseObject exitCode = registryTask.InvokeMethod("SetStringValue",
methodParams, null);
Wmilog.LogInfoWithLevel("in CreateRemoteValue:" + exitCode.ToString(), Log_LoggingLevel.Admin);
}
catch (ManagementException e)
{
Wmilog.LogInfoWithLevel("in CreateRemoteValue(ManagementException):" + e.Message, Log_LoggingLevel.Admin);
return -1;
}
Wmilog.LogInfoWithLevel("注册表键值写入成功!", Log_LoggingLevel.Admin);
return 0;
}
开发者ID:jimidzj,项目名称:Inspect,代码行数:44,代码来源:UtilWMI.cs
示例17: AddPropertiesToList
//-------------------------------------------------------------------------
// Populates the query tab's property list with properties from
// the class in the class list.
//-------------------------------------------------------------------------
private void AddPropertiesToList(object o)
{
int propertyCount = 0;
this.PropertyStatus.Text = "Searching...";
this.PropertyList.Items.Clear();
try
{
// Gets the property qualifiers.
ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementClass mc = new ManagementClass(this.NamespaceList.Text,
this.ClassList.Text, op);
mc.Options.UseAmendedQualifiers = true;
foreach (PropertyData dataObject in
mc.Properties)
{
if (!this.PropertyList.Items.Contains(dataObject.Name))
{
this.PropertyList.Items.Add(
dataObject.Name);
}
propertyCount++;
}
this.PropertyStatus.Text =
propertyCount + " properties found.";
}
catch (ManagementException ex)
{
this.PropertyStatus.Text = ex.Message;
}
}
开发者ID:ctscoville,项目名称:WMIScripter,代码行数:39,代码来源:QueryControl2.cs
示例18: CreateRestorePoint
private void CreateRestorePoint(string description)
{
ManagementScope oScope = new ManagementScope("\\\\localhost\\root\\default");
ManagementPath oPath = new ManagementPath("SystemRestore");
ObjectGetOptions oGetOp = new ObjectGetOptions();
ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);
ManagementBaseObject oInParams =
oProcess.GetMethodParameters("CreateRestorePoint");
oInParams["Description"] = description;
oInParams["RestorePointType"] = 12; // MODIFY_SETTINGS
oInParams["EventType"] = 100;
ManagementBaseObject oOutParams =
oProcess.InvokeMethod("CreateRestorePoint", oInParams, null);
}
开发者ID:rrawla,项目名称:Destroy-Windows-10-Spying,代码行数:16,代码来源:DestroyWindowsSpyingMainForm.cs
示例19: CreateRemoteDirectory
/// <summary>
/// 创建远程目录
/// </summary>
/// <param name="scope">ManagementScope Instance</param>
/// <param name="DirectoryName">要建立的目录名</param>
/// <param name="CurrentDirectory">根目录所在位置,缺省为C:\</param>
/// <returns>0表示建立成功,-1表示建立失败</returns>
public static int CreateRemoteDirectory(ManagementScope scope, string DirectoryName, string CurrentDirectory)
{
try
{
string currentDirectory = CurrentDirectory;
if (String.IsNullOrEmpty(CurrentDirectory))
{
currentDirectory = @"C:\";
}
ObjectGetOptions objectGetOptions = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processBatch = new ManagementClass(scope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processBatch.GetMethodParameters("Create");
inParams["CommandLine"] = @"cmd /CMd " + DirectoryName;
inParams["CurrentDirectory"] = currentDirectory;
ManagementBaseObject outParams = null;
outParams = processBatch.InvokeMethod("Create", inParams, null);
Wmilog.LogInfoWithLevel("Excute CreateRemoteDirectory:" + outParams.ToString(), Log_LoggingLevel.Admin);
}
catch (Exception ex)
{
Wmilog.LogInfoWithLevel("in CreateRemoteDirectory Exception:" + ex.Message, Log_LoggingLevel.Admin);
return -1;
}
Wmilog.LogInfoWithLevel("建远程目录成功!", Log_LoggingLevel.Admin);
return 0;
}
开发者ID:jimidzj,项目名称:Inspect,代码行数:38,代码来源:UtilWMI.cs
示例20: InitializeObject
private void InitializeObject(ManagementScope mgmtScope, ManagementPath path, ObjectGetOptions getOptions)
{
Initialize();
if ((path != null))
{
if ((CheckIfProperClass(mgmtScope, path, getOptions) != true))
{
throw new A
|
请发表评论