zoukankan      html  css  js  c++  java
  • wmi 远程启动程序

    参考网址:https://www.cnblogs.com/HR-LY/p/4969165.html

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Management;

    using System.Management.Instrumentation;

    namespace RemoteStartEXE

    {

      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(@"\" + "IP地址" + @" ootcimv2:Win32_Process");

          ManagementScope scope = new ManagementScope(mngPath, connOption); scope.Connect();

          //ObjectGetOptions 类是指定用于获取管理对象的选项        

          ObjectGetOptions objOption = new ObjectGetOptions();

          //ManagementClass 是表示公共信息模型 (CIM) 管理类,通过该类的成员,可以使用特定的 WMI 类路径访问 WMI 数据 

          ManagementClass classInstance = new ManagementClass(scope, mngPath, objOption);

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

          // Fill in input parameter values 

          //inParams["CommandLine"] = @"D:ProgramUserAnts20120530UserAnts20120530UserAnts3TaskWorker.exe";//只能启动进程

          inParams["CommandLine"] = "schtasks /run /tn "程序启动""; //其中“程序启动”是任务计划的名称,需要建立启动exe的计划任务

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

          ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, methodOptions);
        }

       }

    }

  • 相关阅读:
    02-线性结构2 一元多项式的乘法与加法运算
    两个堆栈实现列队
    队列的顺序存储和链式存储实现
    包含MIN函数的栈+一个数组实现两个堆栈+两个数组实现MIN栈
    利用纯java捕获和播放音频
    许令波老师的java的IO机制分析文章
    soundtouch源码分析__based on csdn :
    java桌面项目打包_by icewee_写得太棒了,直接转载了
    白化检验( 白噪声准则检验 )
    对于冯嘉礼老师定性映射理论的复习
  • 原文地址:https://www.cnblogs.com/bruce1992/p/15351533.html
Copyright © 2011-2022 走看看