我想運行一個命令,在Win 2008框中調用批處理文件。 (當我登錄到Win 2008並單擊時,命令運行成功)。C#WMI遠程進程執行
但是,當我通過WMI使用相同的用戶憑據調用此批處理文件批處理不執行。
我的代碼連接是:
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
connOptions.Username = UserName;
connOptions.Password = Password;
ManagementScope manScope = new ManagementScope(
String.Format(@"\\{0}\ROOT\CIMV2", ComputerName), connOptions);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(
manScope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = command;
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
Object returnValue = outParams["ReturnValue"];
任何幫助表示讚賞...
這是該代碼的執行後的返回值的價值? – RRUZ
返回值爲0 ..我認爲在沒有錯誤時會返回。 – Jimmy
然後執行該命令,但對您不可見。因爲創建方法不能用於遠程啓動交互式進程。 – RRUZ