首页 > 系统相关 >c# 获取指定进程的命令行

c# 获取指定进程的命令行

时间:2023-05-17 09:35:15浏览次数:30  
标签:process string processName c# commandLine System 获取 ManagementObjectSearcher 命令行

using System;
using System.Management;

class Example {
    static void Main(string[] args) {
        string processName = "javaw";  // 进程名称,可根据实际情况进行修改

        ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE Name='" + processName + ".exe'");
        foreach (ManagementObject process in searcher.Get()) {
            string commandLine = process["CommandLine"].ToString();
            Console.WriteLine("Process {0} started with command line: {1}", processName, commandLine);
        }
    }
}

 

标签:process,string,processName,c#,commandLine,System,获取,ManagementObjectSearcher,命令行
From: https://www.cnblogs.com/nanfei/p/17407550.html

相关文章

  • Linux下文本格式异常:with CRLF line terminators
    linux下在处理文本时,有时会遇到列打印或者显示异常:这是因为有些命令输出重写向到文本,会带入默认Windows文本格式,正常的linux文本中每行是以换行符(\n)结束,windows文本中每行是以回车+换行符(\r\n)结束,可以通过dos2unix工具进行转换:通过file文件名命令可以查看输出:linux文本格式为:A......
  • oracle startup命令
    1、https://dianzubuluo.com/%E6%9C%AA%E5%91%BD%E5%90%8D/117215.htmlhttps://wenku.baidu.com/view/2ded5a0bedfdc8d376eeaeaad1f34693dbef1057.html?_wkts_=1684286608746&bdQuery=oracle+startup%E5%91%BD%E4%BB%A4https://blog.csdn.net/weixin_45641933/article/d......
  • centos上使用makefile编译sliver时 提示gcc 错误,cannot find -ldl cannot find -lpth
    github.com/bishopfox/sliver/server/usr/local/go/pkg/tool/linux_amd64/link:runninggccfailed:exitstatus1/usr/bin/ld:cannotfind-ldl/usr/bin/ld:cannotfind-lpthread/usr/bin/ld:cannotfind-lccollect2:error:ldreturned1exitstatus这个错误通常......
  • 低版本docker在dockerfile构建时的NO_PUBKEY问题
     问题我在ubuntu22.04的容器里面运行aptupdate的时候出现了以下报错[root@VM-16-9-centosdocker-kubuntu]#dockerrun--rm-itubuntu:22.04bashroot@8ac245b487e6:/#aptupdateGet:1http://security.ubuntu.com/ubuntujammy-securityInRelease[110kB]Get:2......
  • @ExceptionHandler注解
    1,基本使用方法Spring的@ExceptionHandler可以用来统一处理方法抛出的异常,比如这样:@ExceptionHandler()publicStringhandleExeption2(Exceptionex){System.out.println("抛异常了:"+ex);ex.printStackTrace();StringresultStr="异常:默认";returnr......
  • vscode中vue项目中修改.vue文件名后报错
    报错误信息:Alreadyincludedfilename'.../xxx.vue'differsfromfilename'.../xxx.vue'onlyincasing.Thefileisintheprogrambecause:Importedvia'…/xxx.vue'fromfile'.../xxx.vue'Rootfilespecifiedforcompi......
  • docker
    docker与虚拟机 ......
  • CF1832F Zombies
    简要题意给定\(n\)个左闭右开的区间\(A_i=[L_i,R_i)\),其中\(0\leL_i<R_i\lex\),你可以自由选择\(k\)个长度为\(m\)左闭右开的区间\(B_j=[l_j,r_j)\)使得\(0\lel_j<r_j\lex\)。区间长度定义为内部整点个数。接下来给每个\(A\)中的区间\(A_i\)分配唯一......
  • Redis Cluster两slave节点处理
    背景系统:CentOS7.6RedisClusterIP端口角色192.168.100.116380Master192.168.100.116381slave192.168.100.126380Master192.168.100.126381Slave192.168.100.136380Master192.168.100.136381Slave 因为某种原因导致(192.168.100.12)操......
  • COMP612 图形计算
    COMP612ComputerGraphicsProgrammingSemester1,2023Project:HelicopterSceneThisisanindividualassignment.Allworkyousubmitmustbeentirelyyourown.Theassignmentisworth70%andwillbemarkedoutof100.•Youmustworkfromtheprovidedanima......