2

I have a Word to PDF converter that works from Commandline so we created a middle-ware program to accept commands via Classic ASP. That worked so we then created the middle-ware program as a Windows service and all was working fine until we moved from our dev server (Windows Server 2012) to our production server (Windows Server 2019). Now that Windows service no longer works and spits out errors about not be able to find or connect to COM.

So I dropped the middle-ware Windows service and tried using PHP to run the Word to PDF converter. But that either complains about not finding a COM or just hangs.

The PDF converter dev recommended testing PHP command using XCOPY, and lo and behold the real problem enfolds... PHP does not have the rights/permissions to use XCOPY or the PDF conversion app, or our middle-ware service. An example of the PHP is...

$answer = shell_exec('xcopy /S /I /Q /Y /F "C:\IN\Word.docx" "C:\OUT\"')
echo $answer;

So there must be a difference in security between Windows Server 2012 and 2019. How to fix that and/or give PHP rights to run apps?

Yes, UAC is disabled and the permissions on the IN and OUT folders are read, write, execute for Everyone.

How do I enable PHP run XCOPY commands on Windows Server 2019?

Kendo
  • 149
  • 9

1 Answers1

3

Your code works with PHP on Windows Server 2019. If it is not working on your server try the following:

  1. Check that the PDF install went to C:\PDF\ and and not to C:\program Files\ because a space in that folder name can be a killer for PHP which was designed yo run on Apache and not Windows.

  2. In IIS Manager check the Handler Mappings for PHP. You may find one or two:

  • FastCGI
  • PHP_via_FastCGI

They should both point to C:\PHP\php-cgi.exe

If you still get errors, check C:\Windows\Temp\ for any FastCGI errors.

WilliamK
  • 821
  • 1
  • 13
  • 32
  • I did already have PHP installed into its own folder at root, But I did find that PHP_via_FastCGI was misconfigured and pointing to the old location in Program Files. Not sure if this was done by the PHP installer or one of the PHP management apps that I tried. Anyway, your advice worked and PHP now runs XCOPY ok, thanks. – Kendo Nov 03 '21 at 02:56