Skip to content

Instantly share code, notes, and snippets.

@hzhu212
Last active July 7, 2024 19:24
Show Gist options
  • Save hzhu212/1315d56df5874fe27d754ce7e88c550d to your computer and use it in GitHub Desktop.
Save hzhu212/1315d56df5874fe27d754ce7e88c550d to your computer and use it in GitHub Desktop.
Windows cmd/bat 相关

Windows cmd/bat 相关

后台执行命令

cmd 中后台执行命令,相当于 bash 中的&

start /b <your_command>

输出重定向

方法类似于 bash

<your_command> 1>log.txt 2>&1

bat 脚本后台执行命令并隐藏小黑窗

在 bat 文件的开头加入如下代码:

@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin

之后再正常编写自己的命令即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment