2016-04-20 4 views
1

Versuchen, Beispiel-Batch-Datei von PHP ausführen, um Firefox-Browser zu schließen. aber es schließt die Browser nicht. manuell, wenn Batch-Datei von der Eingabeaufforderung ausführen, es funktioniert.Batch-Datei wird nicht von PHP ausgeführt

closebrowsers.bat

tskill firefox 

close.php

<?php 

exec('cmd /c C:\wamp\www\fedex\closebrowsers.bat'); 

print "done"; 
?> 

mit absolutem Pfad ausprobiert, ohne absolutem Pfad, entweichende Schrägstriche zurück.

exec('cmd /c C:\\wamp\\www\\fedex\\closebrowsers.bat'); 

exec('cmd /c closebrowsers.bat'); 

Antwort

0

Als Alternative zu tskill Sie taskkill verwenden können

<?php 

print `C:\\Windows\\system32\\taskkill.exe /F /IM chrome.exe /T`; 
// or event without the full path to the executable 
// print `taskkill.exe /F /IM chrome.exe /T`; 
// and even without the full executable name 
// print `taskkill /F /IM chrome.exe /T`; 

Will Ausgabe etwas auf den Linien von

SUCCESS: The process with PID 16972 (child process of PID 17912) has been terminated. 
SUCCESS: The process with PID 10200 (child process of PID 17912) has been terminated. 
.... 
SUCCESS: The process with PID 16764 (child process of PID 17912) has been terminated. 
SUCCESS: The process with PID 17912 (child process of PID 2760) has been terminated. 

Keine Notwendigkeit für eine separate Batch-Datei.
/F - endet mit Nachdruck ein Verfahren
/IM - geht einen Bildnamen, ex. chrome.exe
/T - Kindprozesse töten zu

Sie exec anstelle der Graviszeichen Betreiber nutzen können.

Verwandte Themen