I need to run a .bat file from Windows Task Scheduler WTS. If I run the .bat with double click it works. But it isn't working when launching from WTS.
On WTS my action is:
C:\path\file.bat
The file.bat
opens file2.php
, which opens file3.vbs
.
I have this working on other files, also from WTS.
Originaly file.bat
runs directly vbs file without php but it also doesnt work on WTS.
Running each appart works fine, but none works from WTS.
file.bat
c:\wamp64\bin\php\php7.2.10\php.exe -f "C:\wamp64\www\backups\web\file2.php"
file2.php
$comando = "C:\\WINDOWS\\SysWOW64\\wscript.exe C:\\wamp64\\www\\backups\\web\\file3.vbs";
shell_exec($comando);
file3.vbs
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim exeName
Dim fileName
exeName = """%programfiles%\Notepad++
otepad++.exe"""
fileName1 = """C:\wamp64\www\file4.php"""
Call WshShell.Run(fileName1)
WScript.Sleep 2000
WshShell.SendKeys("^+B") ' "^+9" is Ctrl+Shift+9. Replace it with your preferred shortcut.
WScript.Sleep 2000
I am not getting any kind of error on WTS, it just run for a few seconds and ends.
I need it to run even if I am not logged in.
The reason why I am using secuence bat-php-vbs-php
is because I need other things to be done. The full scripts have more than just this, but just like this they are not working.