Running a batch file from windows task scheduler, but hidden or minimized

自闭症网瘾萝莉.ら 提交于 2019-12-24 13:16:40

问题


I am running a .bat file from windows task scheduler every hour, the file is named: followers.bat

And contains:

@ECHO OFF
C:\xampp\php\php.exe -f "C:\xampp\htdocs\Test\FollowTrackerV2\followers.php"

It is entered in the task scheduler like so:

program / script: C:\xampp\htdocs\Test\FollowTrackerV2\followers.bat

parameters (optional): <blank>

Start in (optional): C:\xampp\htdocs\Test\FollowTrackerV2

I tried adding parameter /min but that did not seem to work, it flashed a command prompt like it always does.

I searched around but I did not find a concrete answer, I hope right now in 2015 on windows 8.1 there is a clever / easier way to do this, but I am not aware of that. Hence why I am asking you guys :)

Thanks!


回答1:


You can write a simple VBScript to call the batch file and then use the scheduled task to run the VBScript.

CreateObject("Wscript.Shell").Run "batch-file.bat", 0, True



回答2:


Your question isn't clear, but the code I use to work with windows command line in hidden mode is:

<?php
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("cmd /C C:\xampp\htdocs\Test\FollowTrackerV2\followers.bat", 0); // 0 invisible / 1 visible

Note:

Make sure Apache is running under the same user as you, otherwise it won't work.

To run the apache as the same user as you, first Stop the Apache service and go to, in my case, C:\wamp\bin\apache\apache2.4.9\bin, open a command prompt there and type httpd, now run the code above.



来源:https://stackoverflow.com/questions/30307638/running-a-batch-file-from-windows-task-scheduler-but-hidden-or-minimized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!