Passing all arguments to a FTYPE association?


  1. Posts : 34
    Windows 10
       #1

    Passing all arguments to a FTYPE association?


    Hi. I just rebuilt my box, and I forgot to export my custom file associations. One of them is my configuration to allow PHP files to be ran at a command prompt like EXE files, where I can just type like "imginfo" and if imginfo.php is in the path, it runs it. To achieve that, I had added .PHP to the PATHEXT and assoc'd .php to phpfile, then ftype'd phpfile to point to my php.exe.

    However, when I tried imginfo filename.jpg it complained that I needed to pass a file. I did a var dump and saw that no arguments had been passed. I did some Googling because I thought %* was the ticket but it isn't working. I tried

    ftype phpfile=D:\Utils\PHP\php.exe -f "%1" %*
    ftype phpfile=D:\Utils\PHP\php.exe -f "%1" "%2" "%3" "%4" "%5" ..etc
    ftype phpfile=D:\Utils\PHP\php.exe -f %1 %2 %3 ..etc
    ftype phpfile=D:\Utils\PHP\php.exe -f "%1 %2 %3" ..etc
    ftype phpfile=D:\Utils\PHP\php.exe -f %*
    ftype phpfile=D:\Utils\PHP\php.exe -f "%*"

    ...none of those worked. Does someone know what I need to do to make this work?

    Thanks!
      My Computers


  2. Posts : 844
    Windows 7
       #2

    Google found the PHP docs: Command Line PHP on Microsoft Windows
      My Computer


  3. Posts : 34
    Windows 10
    Thread Starter
       #3

    Thanks. UGH this is so frustrating. I used their reg file, changed it just to point where my PHP is and it still fails to pickup args. I wonder what in the world could be wrong?

    Code:
    D:\Internet\Downloads>assoc .php
    .php=phpfile
    
    D:\Internet\Downloads>ftype phpfile
    phpfile="D:\Utils\PHP\php.exe" -f "%1" -- %~2
    
    D:\Internet\Downloads>copy con test.php
    [?php  var_dump($argv); ?]
    ^Z
            1 file(s) copied.
    
    D:\Internet\Downloads>test 1 2 3 4 5
    array(1) {
      [0]=>
      string(30) "D:\Internet\Downloads\test.php"
    }
    (The PHP tags were actually using < and >, but TenForums blocked me when I tried to post it as is so had to change to [ ])


    Found it. Whilst Googling, someone said that the command line assoc/ftype only works on HKLM and that you need to also be checking HKCU\SOFTWARE\Classes as that takes precedence. Sure enough. in HKCU .php is "php_auto_file" and that was set to just "D:\Utils\PHP\php.exe" "%1". Once I added %* to the end, now it works perfectly.

    Just figured I'd throw that out there for posterity if someone else has the same issue :)
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 05:25.
Find Us




Windows 10 Forums