private void connSer(string User,string Pass,string Server)
{
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("fffffffffff0fffffffffffff");
options.Username = "administrator"; //could be in domain\user format
Console.WriteLine("fffffffffff1fffffffffffff");
options.Password= "xingxinde";
Console.WriteLine("fffffffffff2fffffffffffff");
Console.WriteLine(Server);
Console.WriteLine(Pass);
ManagementScope scope = new ManagementScope("\\\\\miss\\rising$\\rav", options);
Console.WriteLine("fffffffffff3ffffffffffffff");
try
{
scope.Connect();
//ManagementObject disk = new ManagementObject(scope,new ManagementPath("Win32_logicaldisk=Server"),null);
//disk.Get();
}
catch (Exception e)
{
Console.WriteLine("ffffffffffffffffffffffff");
}
}***************************
ManagementScope scope = new ManagementScope("\\\\\miss\\rising$\\rav", options);
运行到上面这句提示“参数无效”
{
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("fffffffffff0fffffffffffff");
options.Username = "administrator"; //could be in domain\user format
Console.WriteLine("fffffffffff1fffffffffffff");
options.Password= "xingxinde";
Console.WriteLine("fffffffffff2fffffffffffff");
Console.WriteLine(Server);
Console.WriteLine(Pass);
ManagementScope scope = new ManagementScope("\\\\\miss\\rising$\\rav", options);
Console.WriteLine("fffffffffff3ffffffffffffff");
try
{
scope.Connect();
//ManagementObject disk = new ManagementObject(scope,new ManagementPath("Win32_logicaldisk=Server"),null);
//disk.Get();
}
catch (Exception e)
{
Console.WriteLine("ffffffffffffffffffffffff");
}
}***************************
ManagementScope scope = new ManagementScope("\\\\\miss\\rising$\\rav", options);
运行到上面这句提示“参数无效”
解决方案 »
- c# 中关于base.get_Item("Path")的问题
- 读取excel第一个工作表名
- 如何设置解决方案资源管理器、属性窗口的字体大小
- 【求救啊】数据导入搞了好多天了!没头绪,大家帮帮忙!
- 怎么把一个表追加到DS中?
- 关于Sockets 接收数据返回分屏数据和返回数据乱码的问题
- winform线程问题
- if(cookie==null||cookie.ToString()=="")是正常的,但改成if(cookie!=null||cookie.ToString()!="")就提示:未将对象引用设置到对象的实
- 求c#的mscomm控件的相信使用说明或样例程序
- 怎么使用鼠标在窗体上画直线?
- 求助C#中对不同数据类型进行相同计算的方法
- web.config整合问题
{
ConnectionOptions options = new ConnectionOptions();
Console.WriteLine("fffffffffff0fffffffffffff");
options.Username = "administrator"; //could be in domain\user format
Console.WriteLine("fffffffffff1fffffffffffff");
options.Password= "xingxinde";
Console.WriteLine("fffffffffff2fffffffffffff");
Console.WriteLine(Server);
Console.WriteLine(Pass);
ManagementScope scope = new ManagementScope(@"\\\\\miss\\rising$\\rav", options);
Console.WriteLine("fffffffffff3ffffffffffffff");
try
{
scope.Connect();
//ManagementObject disk = new ManagementObject(scope,new ManagementPath("Win32_logicaldisk=Server"),null);
//disk.Get();
}
catch (Exception e)
{
Console.WriteLine("ffffffffffffffffffffffff");
}
} 如果加上@也不成的话 那就是参数有问题
@"\\miss\rising$\rav"和“\\\\miss\rising$\rav”多不行
// if you plan to connect to the remote
// computer with a different user name
// and password than the one you are currently using.
// This example uses the default values. ConnectionOptions options =
new ConnectionOptions(); // Make a connection to a remote computer.
// Replace the "FullComputerName" section of the
// string "\\\\FullComputerName\\root\\cimv2" with
// the full computer name or IP address of the
// remote computer.
ManagementScope scope =
new ManagementScope(
"\\\\FullComputerName\\root\\cimv2", options);
scope.Connect(); //Query system for Operating System information
ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, query); ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
// Display the remote computer information
Console.WriteLine("Computer Name : {0}",
m["csname"]);
Console.WriteLine("Windows Directory : {0}",
m["WindowsDirectory"]);
Console.WriteLine("Operating System: {0}",
m["Caption"]);
Console.WriteLine("Version: {0}", m["Version"]);
Console.WriteLine("Manufacturer : {0}",
m["Manufacturer"]);
}