如何在运行 .bat 文件时隐藏 ms-dos 窗口?

如何在运行 .bat 文件时隐藏 ms-dos 窗口?

我每分钟运行一个 .bat 文件来执行我的脚本 (Scheduled Tak (CronJob))。当它运行时,似乎 MS-DOS 窗口的时间很短。我的批处理代码如下;

@ECHO OFF C:\wamp\bin\php\php5.4.3\php.exe -f "C:\wamp\www\tst\index.php"

运行时如何隐藏该窗口?

答案1

您可以使用 VB 脚本隐藏窗口:

Set objArgs = WScript.Arguments
For Each strArg in objArgs
    Set WshShell = CreateObject("WScript.Shell")
    cmds=WshShell.RUN(strArg, 0, False)
    Set WshShell = Nothing
Next

start c:\runHidden.vbs "C:\wamp\bin\php\php5.4.3\php.exe -f 'C:\wamp\www\tst\index.php'"

答案2

您可以使用start /min <your command>它,它不会隐藏窗口但会将其最小化。

答案3

在 中Task Scheduler,您可以创建一个将在另一个用户帐户中运行的任务。如果这样做,批处理窗口将不会出现在您自己的登录名中。

答案4

echo N > I.tmp & (if "%1"=="Not" (echo Ready > I.tmp & goto :Skip )) &     findstr /c:"Ready" I.tmp & (if not errorlevel 1 (set e=Not))& (if not exist Script.bat Set e=Is) & (set a=) & (set /a a=%random%) & (if "%1"=="Not" goto :Skip) &  (Set a=) & (set b=) & (set Var=) & (set VarA=) & (Set VarB=)& (Set VarC=)& (Set VarD=)  & set /a b=0 & cd "%myfiles%" & set Var=%1 & set VarA=%2 & set VarB=%3 & set VarC=%4 & Set VarD=%5
:9
@shift /1 & set Var=%Var% %1 & set VarA=%VarA% %2 & set VarB=%VarB% %3 & set VarC=%VarC% %4 & Set VarD=%VarD% %5 & (if "%1"=="" goto :8)  &goto :9
:8
Set Var=%Var% & Set VarA=%VarA% & Set VarB=%VarB% & Set VarC=%VarC% & Set VarD=%VarD% & (if not "%1"=="Not" (echo %~nx0 Not %Var% > Script.bat & echo createobject^("Wscript.shell"^).run "cmd.exe /c Script.bat",0,0 > Script.vbe & Wscript //B Script.vbe & timeout -t 1 >NUL & exit) )
:Skip


if exist Script.bat del Script.bat /Q
if exist Script.vbe del Script.vbe /Q

REM 将其包含在脚本的开头。

相关内容