简体   繁体   中英

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"

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.

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


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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