ConnectionOptions connection = new ConnectionOptions();
//just username, without domain name, otherwise, a "RPC is Unavaliable." exception will be thrown.
connection.Username = "testUser";
connection.Password = "testPassword";
//Allow privilege
connection.EnablePrivileges = true;
connection.Impersonation = ImpersonationLevel.Delegate;
connection.Authentication = AuthenticationLevel.Call;
//Neither ntdlmdomain or kerberoes, otherwise, a "Invalid Parameter." exception will be thrown.
connection.Authority = "ntlmdomain:MYDOMAIN";
//IP Address or host full name.
ManagementScope scope = new ManagementScope("\\\\myIPAddress\\root\\CIMV2", connection);
scope.Connect();
ManagementClass classInstance = new ManagementClass(scope,new ManagementPath("Win32_Process"), null);
ManagementBaseObject inParams = classInstance.GetMethodParameters("Create");
//Change it to your own execute file path
inParams["CommandLine"] = "myExecuteFilePath";
ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, null);
什麼是你新文件的位置?你是以管理員還是以用戶身份運行應用程序?在Windows Vista或最近您需要提升權限才能在位置創建文件,如Program Files – 2011-04-01 09:20:09
它被稱爲UAC;看到[我的答案在這裏](http://stackoverflow.com/questions/5210575/does-windows-7-have-the-same-problem-as-vista/5210642#5210642)瞭解更多詳情。您不應該首先寫入系統文件夾。但是,如果你絕對必須,我只是寫了一個關於如何在C#中提升應用程序過程的詳細解釋[回覆此問題](http://stackoverflow.com/questions/5507818/workaround-against-registry-manipulation -limitation式 - 窗口五百五十零萬八千分之七#5508000)。 – 2011-04-01 09:22:52