iT邦幫忙

0

關於遠端存取wmi權限問題

各位前輩好,我指令使用net use時一直無完成目地,但確可以使用shutdown,我覺得應該是權限的問題,但我設定COM的安全性,甚至設成everyone都還是不行,在不使用pstool的情狀(連線等待較久)下想請問前輩問一些意見,謝謝。

            string path = @"net use x: \\192.168.11.1\share ""密碼"" /user:administrator";
            Response.Write(path);
            ConnectionOptions options = new ConnectionOptions();
            options.Username = @"zealot\administrator";   // 使用者名稱
            options.Password = @"qscesz135@$^";   // 使用者密碼
            options.Authentication = AuthenticationLevel.PacketPrivacy;    // 認證模式設定 (採用預設)
            options.Impersonation = ImpersonationLevel.Impersonate;  // 設定 COM 模擬等級
            options.EnablePrivileges = true;  // 參考 **(特一)
            //options.Authority = "ntdlmdomain:domain";  
            ManagementScope MS_Conn = new ManagementScope("\\\\" + "192.168.10.246" + "\\root\\cimv2", options);
            //ManagementScope MS_Conn = new ManagementScope("\\\\" + ip.Text + "\\root\\DEFAULT", options);
            MS_Conn.Connect();

            ManagementPath MP = new ManagementPath("Win32_Process");//要先知道命令的大類
            ManagementClass processClass = new ManagementClass(MS_Conn, MP, null);
            ManagementBaseObject mbo = processClass.GetMethodParameters("Create");//方法
            mbo["CommandLine"] = string.Format("cmd.exe /c {0}",path);//指令
            ManagementBaseObject result = processClass.InvokeMethod("Create", mbo,null);//處發
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

10
蟹老闆
iT邦大師 1 級 ‧ 2013-03-06 19:04:20
最佳解答

string path = @"net use x: \\192.168.11.1\share ""密碼"" /user:administrator";

net use 的使用方式應為:
net use x: \\192.168.11.1\share /user:administrator 密碼
這樣才對,密碼寫在/user前會造成找不到路徑
以上供參考。

timtam iT邦新手 5 級 ‧ 2013-03-07 10:33:33 檢舉

前輩您好,我剛剛試著把密碼輸入在後方還是不行。
目前把指令丟在cmd.exe 執行是可以run的。

我要發表回答

立即登入回答