Quantcast
Channel: iT邦幫忙
Viewing all articles
Browse latest Browse all 15645

關於遠端存取wmi權限問題

$
0
0
各位前輩好,我指令使用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);//處發

Viewing all articles
Browse latest Browse all 15645

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>