2

I am running a .bat file for my script (Scheduled Tak (CronJob)) per minute. When it run, seems ms-dos window short period of time. My batch code like this;

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

How can I hide this window when it run?

4 Answers 4

7

You can hide the window with a VB script:

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'"
0
1

You can use start /min <your command> which will not hide window but will minimize it.

0

In Task Scheduler, you may create a task that will run in another user account. If done so, the batch window won't appear in your own login.

0
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 Include this in the beginning of your script.

2
  • Could you please clarify your proposal? Mar 15, 2019 at 8:35
  • It quickly hides it. Might just use a compiler instead. This is very old stuff I did. Oct 26, 2020 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .