国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

wmi C# 遠程啟動exe文件,有界面

2019-11-17 03:07:09
字體:
來源:轉載
供稿:網友

wmi C# 遠程啟動exe文件,有界面

由于業務需要,需要批量遠程服務器,啟動對應的exe文件。我最初也只是做到了啟動的文件在進程中,不能界面顯示,通過請教運維,通過任務計劃能啟動帶界面的程序,注意計算機需要開啟遠程桌面,注意防火墻,我是直接把火墻關閉了,網上說例外135端口也可,沒有試驗,下面是我test的一個demo。

直接上代碼吧:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Management;using System.Management.Instrumentation;

namespace test1{ class windowsWmi {

public void exStartCommand() { //ConnectionOptions指定生成wmi連接所需的設置 string userName = "用戶名"; string passWord = "密碼"; ConnectionOptions connOption = new ConnectionOptions(); connOption.Username = userName; connOption.Password = password; //ManagementPath包裝了生成和分析wmi對象的路徑 ManagementPath mngPath = new ManagementPath(@"http://" + "

ManagementBaSEObject inParams = classInstance.GetMethodParameters("Create");

// Fill in input parameter values //inParams["CommandLine"] = @"D:/Program/UserAnts20120530/UserAnts20120530/UserAnts3/TaskWorker.exe";//只能啟動進程 inParams["CommandLine"] = "schtasks /run /tn /"Start03/""; //其中Start03是任務計劃的名稱,需要建立啟動exe的計劃任務

// Method Options InvokeMethodOptions methodOptions = new InvokeMethodOptions(null, System.TimeSpan.MaxValue);

// Execute the method ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, methodOptions); //Console.WriteLine("Creation of calculator process returned: " + outParams["returnValue"]); //Console.WriteLine("Process ID: " + outParams["processId"]); } }}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 温泉县| 南皮县| 沂南县| 东平县| 石棉县| 涪陵区| 乌海市| 迭部县| 台东市| 札达县| 西乌珠穆沁旗| 江西省| 三都| 德惠市| 青冈县| 乐平市| 教育| 红原县| 禹州市| 阳高县| 衡山县| 澄城县| 昭觉县| 绥滨县| 天镇县| 鄂州市| 达尔| 民权县| 唐山市| 铜鼓县| 灵山县| 乌拉特前旗| 资源县| 博罗县| 望城县| 南澳县| 天等县| 天祝| 紫金县| 凤庆县| 高清|