简体   繁体   English

从Windows Task Scheduler运行批处理文件,但隐藏或最小化

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

I am running a .bat file from windows task scheduler every hour, the file is named: followers.bat 我每小时从Windows Task Scheduler运行一个.bat文件,该文件名为: 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 program / script: C:\\xampp\\htdocs\\Test\\FollowTrackerV2\\followers.bat

parameters (optional): <blank> parameters (optional): <blank>

Start in (optional): C:\\xampp\\htdocs\\Test\\FollowTrackerV2 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. 我尝试添加参数/min但是似乎不起作用,它像往常一样闪烁命令提示符。

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. 我四处搜寻,但没有找到具体的答案,我希望现在在2015年Windows 8.1上,有一个聪明/简单的方法可以做到这一点,但我不知道。 Hence why I am asking you guys :) 因此,为什么我要问你们:)

Thanks! 谢谢!

您可以编写一个简单的VBScript来调用批处理文件,然后使用计划的任务来运行VBScript。

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

Your question isn't clear, but the code I use to work with windows command line in hidden mode is: 您的问题尚不清楚,但是我在隐藏模式下用于Windows命令行的代码是:

<?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. 确保Apache与您在同一用户下运行,否则它将无法正常工作。

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. 要以与您相同的用户身份运行apache,首先停止Apache服务,并以我为例,转到C:\\wamp\\bin\\apache\\apache2.4.9\\bin ,在此处打开命令提示符并键入httpd ,然后运行上面的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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