Created
December 1, 2009 17:40
-
-
Save pwlin/246475 to your computer and use it in GitHub Desktop.
Calling PHP CLI from ActiveX FSO and WScript.Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var php = { | |
cmd : function(command, nWindowType){ | |
// Obtain a Temporary File Name | |
var oFS ; | |
var RunOutput = '' ; | |
oFS = new ActiveXObject("Scripting.FileSystemObject"); | |
var cFile ; | |
cFile = oFS.GetSpecialFolder(2).Path+'\\'+ oFS.GetTempName() ; | |
// Execute the command and redirect the output to the file | |
var oShell ; | |
oShell = new ActiveXObject("WScript.Shell"); | |
oShell.Run(command + " >" + cFile, nWindowType, true); | |
oShell = null ; | |
// Read output file and return | |
var oFile ; | |
oFile = oFS.OpenTextFile(cFile, 1, true) ; | |
RunOutput = oFile.ReadAll() ; | |
oFile.Close() ; | |
// Delete Temporary File | |
oFS.DeleteFile(cFile); | |
oFS = null ; | |
cFile = null ; | |
return RunOutput ; | |
} | |
} | |
// output = php.cmd('command /c php -v ', 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment