简体   繁体   English

在 Windows 命令提示符中关闭窗口

[英]Close a Window in Windows Command Prompt

Hey I've got a quick question,嘿,我有一个简短的问题,

I know that you can start applications minimized through the command prompt with something like:我知道您可以通过命令提示符启动最小化的应用程序,例如:

start /min "" "C:\\Windows\\notepad.exe"启动 /min "" "C:\\Windows\\notepad.exe"

However is there a way to automatically close the window, now I don't mean kill the process/task.但是有没有办法自动关闭窗口,现在我不是说杀死进程/任务。 Just close the window.关上窗户就行了。 In notepads case this would work the same way as killing the process, but in something that will minimize to a system tray on a window close, like Skype, or Discord for example this wouldn't kill the process but instead just put the task away from sight.在记事本的情况下,这与终止进程的工作方式相同,但在关闭窗口时将最小化到系统托盘的某些东西,例如 Skype 或 Discord,这不会终止进程,而只是将任务放在一边从视线。

Thanks谢谢

This is not possible in batch files alone, instead this script creates a temporary VBScript at %temp%\\hidden.vbs and then passes arguments to it using wscript.exe这在单独的批处理文件中是不可能的,而是该脚本在%temp%\\hidden.vbs创建一个临时 VBScript,然后使用wscript.exe将参数传递给它


This script doesn't minimise it or send it to the system tray, it just hides it and is only visible in Task Manager此脚本不会将其最小化或将其发送到系统托盘,它只是将其隐藏并且仅在任务管理器中可见

@echo off
(echo CreateObject^("Wscript.Shell"^).Run """" ^& WScript.Arguments^(0^) ^& """", 0, False) > "%temp%\hidden.vbs"
set launch=wscript.exe "%temp%\hidden.vbs"


%launch% notepad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM