PHP executes cscript on Windows 7 .

Discuss server installationa nd configuration issues here

Moderators: macek, egami, gesf

Pily
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Oct 10, 2012 7:59 pm

PHP executes cscript on Windows 7 .

Postby Pily » Wed Oct 10, 2012 8:07 pm

I code a php page and javascript and a bat on windows 7 for converting a word document to pdf in office origin plugin.But it does not effect.And the CPU is very high , but the background program do not run .
the code is :
convert.js
var fso = new ActiveXObject("Scripting.FileSystemObject");
var docPath = WScript.Arguments(0);

docPath = fso.GetAbsolutePathName(docPath);
var pdfPath = docPath.replace(/\.doc[^.]*$/,".pdf");
var objWord = null;

try
{
WScript.Echo("Saving '" + docPath + "' as '" + pdfPath + "' ...");
objWord = new ActiveXObject("Word.Application");
objWord.Visible = false;

var objDoc = objWord.Documents.Open(docPath);

var wdFormatPdf = 17;
objDoc.SaveAs(pdfPath,wdFormatPdf);
objDoc.close();
WScript.Echo("Done.");
}finally{
if(objWord != null)
{
objWord.Quit();
}
}
convert.bat :
@echo off
cscript.exe //logo convert.js F:\a.doc

the PHP page :
<?php
set_time_limit(0);
error_reporting(E_ALL);
$path = $_GET['path'];
if( !$path)
{
$path = "F:\\a.doc";

}
echo $path;
// $cmd ="cscript.exe //logo F:\\workspaces\\PHP\\test\\convert.js " + $path;
$cmd = "convert.bat";
$output = array();
$return_array = 0;
$return = '';
try{
$return = exec($cmd,$output,$return_array);
// $return = exec("dir",$output,$return_array);
}catch (Exception $ex)
{
echo 'ERROR';
}
var_dump($output);
echo "----------------------";
var_dump($return_array);
echo "----------------------";
var_dump($return);
echo "-----------------------";
?>
Please help me! Thanks very much!

Return to “Server installation and configuration”

Who is online

Users browsing this forum: No registered users and 1 guest

cron