首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >taskkill /f /im *.exe 的作用

taskkill /f /im *.exe 的作用

作者头像
ccf19881030
发布于 2021-07-27 07:08:19
发布于 2021-07-27 07:08:19
1.9K00
代码可运行
举报
文章被收录于专栏:ccf19881030的博客ccf19881030的博客
运行总次数:0
代码可运行

最近在看到一个同事使用Qt编写的进程监控程序中使用taskkill命令根据进程名称来杀死进程, 关于taskkill命令的具体用法可以参考MSDN文档:taskkill

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
taskkill [/s <computer> [/u [<domain>\]<username> [/p [<password>]]]] {[/fi <filter>] [...] [/pid <processID> | /im <imagename>]} [/f] [/t]

参数

描述

/s

Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer.

/u <username>

Runs the command with the account permissions of the user who is specified by or by <username>. The /u parameter can be specified only if /s is also specified. The default is the permissions of the user who is currently logged on to the computer that is issuing the command.

/p

Specifies the password of the user account that is specified in the /u parameter.

/fi

Applies a filter to select a set of tasks. You can use more than one filter or use the wildcard character (*) to specify all tasks or image names. The valid filters are listed in the Filter names, operators, and values section of this article.

/pid

Specifies the process ID of the process to be terminated.

/im

Specifies the image name of the process to be terminated. Use the wildcard character (*) to specify all image names.

/f

Specifies that processes be forcefully ended. This parameter is ignored for remote processes; all remote processes are forcefully ended.

/t

Ends the specified process and any child processes started by it.

taskkill是Windows命令行里终止指定程序“进程”的命令。

/f 表示强制终止 /im 表示指定的进程名称,例如“explor.exe"

如果不使用名称,使用进程号,则用/PID,例如(假设已知道某进程的PID号是3352,PID号可以在windows任务管理器中查看): taskkill /f /pid 3352

使用场景:

会在开发定时脚本中用到,用于关闭进程;当然也可以用于进程监控程序的编写,例如如下的Qt代码片段:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
void ProViewWidget::onBtnClicked()
{
	// 处理启动和停止按钮事件
	if (m_bRunning)
	{
		QFileInfo finfo(str2qstr(m_pcfg->exePath));

		std::string temp = std::string("TASKKILL /F /IM ") + qstr2str(finfo.fileName());
		//system(temp.c_str());
		WinExec(temp.c_str(), 0);

		if (m_pcfg->exePath.find("CD-IOT-MQ-Cli-") != m_pcfg->exePath.npos
			|| m_pcfg->exePath.find("CD-IOT-Cli-") != m_pcfg->exePath.npos)
		{
			WinExec("TASKKILL /F /IM node.exe", 0);	
		}
	}
	else
	{
		STARTUPINFO si;
		PROCESS_INFORMATION pi;

		char path[1000] = {NULL};

		std::string strpath = m_pcfg->exePath;

		strcpy(path, strpath.c_str());

		ZeroMemory(&si, sizeof(si));
		si.cb = sizeof(si);
		ZeroMemory(&pi, sizeof(pi));
		if (!CreateProcessA(NULL,   // No module name (use command line)
			path,        // Command line
			NULL,           // Process handle not inheritable
			NULL,           // Thread handle not inheritable
			FALSE,          // Set handle inheritance to FALSE
			0,              // No creation flags
			NULL,           // Use parent's environment block
			NULL,           // Use parent's starting directory 
			&si,            // Pointer to STARTUPINFO structure
			&pi)           // Pointer to PROCESS_INFORMATION structure
			)
		{
			inputLineToEdit("进程启动失败!");
		}
	}
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/07/23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
告别宕机!KubeSphere v4.1.3 联手 K8s v1.32.5,手把手教你打造“永不掉线”的云原生底座
各位读者,好久不见,我是术哥,那个带你玩转 KubeSphere 实战的我又回来了!
运维有术
2025/06/16
6060
告别宕机!KubeSphere v4.1.3 联手 K8s v1.32.5,手把手教你打造“永不掉线”的云原生底座
基于 KubeSphere 玩转 k8s 第二季|KubeKey 扩容 Kubernetes Worker 节点实战
上一期,我们实战讲解了使用 KubeSphere 开发的 KubeKey 工具自动化部署 3 Master 和 1 Worker 的 Kubernetes 集群和 KubeSphere。
运维有术
2023/07/16
6010
手把手教你离线部署 KubeSphere v4.1.2 和 k8s v1.30.6,超详细指南!
今天分享的主题是:如何在离线环境部署 Kubernetes v1.30.6 和 KubeSphere v4.1.2 高可用集群。
运维有术
2025/01/22
2.4K2
手把手教你离线部署 KubeSphere v4.1.2 和 k8s v1.30.6,超详细指南!
手把手教你离线部署 KubeSphere v4.1.2 和 k8s v1.30.6,超详细指南!
今天分享的主题是:如何在离线环境部署 Kubernetes v1.30.6 和 KubeSphere v4.1.2 高可用集群。
运维有术
2025/01/22
1.7K1
手把手教你离线部署 KubeSphere v4.1.2 和 k8s v1.30.6,超详细指南!
基于 KubeSphere 玩转 k8s 第二季|openEuler 22.03 安装 KubeSphere 实战入门
基于 KubeSphere 玩转 K8s 第二季系列文档,基于开源国产化操作系统 openEuler 全新打造,也算是在推进国产化浪潮、CentOS搞事情不能用等综合原因下的一种新的尝试。
运维有术
2023/07/16
9830
ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南
本文介绍了如何在 openEuler 22.03 LTS SP2 aarch64 架构服务器上部署 KubeSphere 和 Kubernetes 集群。我们将使用 KubeSphere 开发的 KubeKey 工具实现自动化部署,在三台服务器上实现高可用模式最小化部署 Kubernetes 集群和 KubeSphere。
运维有术
2023/10/18
9620
ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南
信创:鲲鹏(arm64)+麒麟(kylin v10)离线部署k8s和kubesphere(含离线部署新方式)
先说新方式结论:不论什么CPU架构和操作系统,只要在线能安装的,统统都可以离线安装的。
编码如写诗
2024/08/30
1.8K0
信创:鲲鹏(arm64)+麒麟(kylin v10)离线部署k8s和kubesphere(含离线部署新方式)
基于 KubeSphere 玩转 Kubernetes 第二季|KubeKey 扩容 Kubernetes v1.24 Worker 节点实战
本文是 openEuler 22.03 LTS SP2 基于 KubeKey 扩容 Kubernetes Worker 节点实战一文的更新版。
运维有术
2023/07/20
4280
基于 KubeSphere 玩转 Kubernetes 第二季|KubeKey 扩容 Kubernetes v1.24 Worker 节点实战
最新 KubeKey 3.1.5 离线部署KubeSphere 3.4.1+k8s(更容易了)
点击公众号关注后,回复ks3.4离线包获取 本文制品和镜像。有任何问题可点击联系我,添加微信进行咨询和反馈。
编码如写诗
2024/08/30
1.3K0
最新 KubeKey 3.1.5 离线部署KubeSphere 3.4.1+k8s(更容易了)
KubeSphere 最佳实战:一文搞定 KubeKey v3.1.1 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.28
今天分享的内容是 KubeSphere 最佳实战「2024」 系列文档中的 一文搞定 KubeKey v3.1.1 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.28。
运维有术
2024/05/21
1.4K2
KubeSphere 最佳实战:一文搞定 KubeKey v3.1.1 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.28
KubeKey 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.26 实战指南
KubeKey 从 v2.1.0 版开始新增了清单 (manifest) 和制品 (artifact) 的概念,为用户离线部署 KubeSphere 和 Kubernetes 集群提供了一种简单便捷的解决方案。
运维有术
2023/12/13
2.4K0
KubeKey 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.26 实战指南
KubeSphere 最佳实战:征服 Docker 镜像访问限制!KubeSphere v3.4.1 成功部署全攻略
近期,KubeSphere 社区的讨论中频繁出现关于 Docker 官方镜像仓库访问受限的问题。 尽管用户尝试通过设置 KKZONE=cn 来解决,但部署 KubeSphere 时仍面临失败的情况。
运维有术
2024/07/29
1.1K0
KubeSphere 最佳实战:征服 Docker 镜像访问限制!KubeSphere v3.4.1 成功部署全攻略
KubeSphere 最佳实战:KubeKey 扩容 Kubernetes Worker 节点实战指南
今天分享的内容是 KubeSphere 最佳实战「2024」 系列文档中的 KubeKey 扩容 Kubernetes Worker 节点实战指南。
运维有术
2024/07/16
4901
KubeSphere 最佳实战:KubeKey 扩容 Kubernetes Worker 节点实战指南
33 张高清大图,带你玩转 KubeSphere v4.1.2 部署与扩展组件安装
备受瞩目的 KubeSphere v4.1.2 已经正式官宣发布,该版本带来了一个重大优化:增加默认的扩展组件仓库。
运维有术
2024/11/12
9960
33 张高清大图,带你玩转 KubeSphere v4.1.2 部署与扩展组件安装
ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南(2)
本文是 ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南 的续集,受限于字符数量限制,无奈只能将完整的文档拆成了两篇。
运维有术
2023/10/19
1K0
ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南(2)
33 张高清大图,带你玩转 KubeSphere v4.1.2 部署与扩展组件安装
备受瞩目的 KubeSphere v4.1.2 已经正式官宣发布,该版本带来了一个重大优化:增加默认的扩展组件仓库。
运维有术
2024/11/11
4800
33 张高清大图,带你玩转 KubeSphere v4.1.2 部署与扩展组件安装
KubeSphere 最佳实战:14 张高清大图带你抢先体验 KubeSphere v4.1.1, AIO 部署全攻略
2024年 9月 9号,备受广大网友期待的 KubeSphere v4 终于在GitHub 代码仓库发布了正式的代码,而且是直接越过了 v4.0 直接发布的 v4.1.1。
运维有术
2024/09/14
7020
KubeSphere 最佳实战:14 张高清大图带你抢先体验 KubeSphere v4.1.1, AIO 部署全攻略
ARM 版 Kylin V10 部署 KubeSphere v3.4.0 不完全指南
本文介绍了如何在 麒麟 V10 aarch64 架构服务器上部署 KubeSphere 和 Kubernetes 集群。我们将使用 KubeSphere 开发的 KubeKey 工具实现自动化部署,在三台服务器上实现高可用模式最小化部署 Kubernetes 集群和 KubeSphere。
运维有术
2023/11/09
1.6K1
ARM 版 Kylin V10 部署 KubeSphere v3.4.0 不完全指南
KubeSphere 最佳实战:征服 Docker 镜像访问限制:单节点 KubeSphere v3.4.1 部署攻略
KubeSphere 是在 Kubernetes 之上构建的面向云原生应用的分布式操作系统,完全开源,支持多云与多集群管理,提供全栈的 IT 自动化运维能力,简化企业的 DevOps 工作流。
运维有术
2024/07/29
5490
KubeSphere 最佳实战:征服 Docker 镜像访问限制:单节点 KubeSphere v3.4.1 部署攻略
41 张高清大图带你抢先体验 KubeSphere v3.4.0 和 Kubernetes v1.27
首先声明,我不是标题党,本文初始目标是要体验用 KubeKey v3.0.9 部署最新版的 KubeSphere v3.4.0 和 Kubernetes v1.27,无奈部署过程中发现了自认为的 Bug,进行不下去了,不得不改换 Kubernetes v1.26。
运维有术
2023/07/29
1.8K1
41 张高清大图带你抢先体验 KubeSphere v3.4.0 和 Kubernetes v1.27
推荐阅读
告别宕机!KubeSphere v4.1.3 联手 K8s v1.32.5,手把手教你打造“永不掉线”的云原生底座
6060
基于 KubeSphere 玩转 k8s 第二季|KubeKey 扩容 Kubernetes Worker 节点实战
6010
手把手教你离线部署 KubeSphere v4.1.2 和 k8s v1.30.6,超详细指南!
2.4K2
手把手教你离线部署 KubeSphere v4.1.2 和 k8s v1.30.6,超详细指南!
1.7K1
基于 KubeSphere 玩转 k8s 第二季|openEuler 22.03 安装 KubeSphere 实战入门
9830
ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南
9620
信创:鲲鹏(arm64)+麒麟(kylin v10)离线部署k8s和kubesphere(含离线部署新方式)
1.8K0
基于 KubeSphere 玩转 Kubernetes 第二季|KubeKey 扩容 Kubernetes v1.24 Worker 节点实战
4280
最新 KubeKey 3.1.5 离线部署KubeSphere 3.4.1+k8s(更容易了)
1.3K0
KubeSphere 最佳实战:一文搞定 KubeKey v3.1.1 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.28
1.4K2
KubeKey 离线部署 KubeSphere v3.4.1 和 Kubernetes v1.26 实战指南
2.4K0
KubeSphere 最佳实战:征服 Docker 镜像访问限制!KubeSphere v3.4.1 成功部署全攻略
1.1K0
KubeSphere 最佳实战:KubeKey 扩容 Kubernetes Worker 节点实战指南
4901
33 张高清大图,带你玩转 KubeSphere v4.1.2 部署与扩展组件安装
9960
ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南(2)
1K0
33 张高清大图,带你玩转 KubeSphere v4.1.2 部署与扩展组件安装
4800
KubeSphere 最佳实战:14 张高清大图带你抢先体验 KubeSphere v4.1.1, AIO 部署全攻略
7020
ARM 版 Kylin V10 部署 KubeSphere v3.4.0 不完全指南
1.6K1
KubeSphere 最佳实战:征服 Docker 镜像访问限制:单节点 KubeSphere v3.4.1 部署攻略
5490
41 张高清大图带你抢先体验 KubeSphere v3.4.0 和 Kubernetes v1.27
1.8K1
相关推荐
告别宕机!KubeSphere v4.1.3 联手 K8s v1.32.5,手把手教你打造“永不掉线”的云原生底座
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档