2

I'm having issues similar to some other people, however I've tried multiple things with no resolution.

I've created a very small, simple test script to show what happens.

<?php
    print "In Script!\n";

    var_dump($argv);

?>

Ok, now i can run it with the following command:-

C:\TEMP>  c:\php\php.exe  hughTest.php 1 2 3 4

Output:-

In Script!
array(4) {
[0]=>
string(12) "hughTest.php"
[1]=>
string(1) "1"
[2]=>
string(1) "2"
[3]=>
string(1) "3"
}

Which is good, this is what I'm expecting. Now just running script as .php:-

C:\TEMP> hughTest.php 1 2 3

Output:-

In Script!
array(1) {
[0]=>
string(20) "C:\temp\hughTest.php"
}

This is NOT what I expected! Where have the parameters gone?

I've checked/tried to modify the file associations with no change in output. I've also tried a few different versions of PHP. (5.4 and 5.5). w32 on x64.

Association: .php = phpfile

ftype: phpfile="C:\php\php.exe" "%1" -- %*

also tried:-

phpfile="C:\php\php.exe" "%1" -- %~2

phpfile="C:\php\php.exe" "%1" %*

phpfile="C:\php\php.exe" "%1" -- "%*"

All with the same results.

Any suggestions on where to look next?

Hugh

Hugh
  • 33
  • 4
  • On MSDN to check if `%*` is supported in that context? Just because the shell supports it doesn't mean all other parts of Windows also do. – Jon May 23 '14 at 20:33
  • That works on windows XP for sure. However it's not working on Windows 8.1 or Windows 2008. I also tried %2 %3 %4 and some other options. With and without quotes. It's just as if it's ignoring anything else. I've even tried using things like: "Scooby" thinking that it should show up as a parameter, but it doesn't. – Hugh May 23 '14 at 21:46
  • I've also tried it both under an administrative shell and without. Same result. – Hugh May 23 '14 at 21:48
  • I found a solution! Apparently it's not enough to set the file association in the later windows, you need to also modify the registry. http://stackoverflow.com/questions/4234581/argv-is-empty-using-activeperl-in-windows-7 – Hugh May 23 '14 at 22:13

1 Answers1

1

Solution:-

Based off of this:-

@ARGV is empty using ActivePerl in Windows 7

Basically you need to also modify the Windows Registry

[HKEY_CLASSES_ROOT/Applications/php.exe/shell/open/command]
  change the data to something like: "c:\php\php.exe" "%1" %*

[HKEY_CLASSES_ROOT\php_auto_file\shell\open\command]
  change the data to something like: "c:\php\php.exe" "%1" %*

[HKEY_CLASSES_ROOT\phpfile\shell\open\command]
  change the data to something like: "c:\php\php.exe" "%1" %*

Which now results in:-

C:\temp>hughTest.php 1 2 3
In Script!
array(4) {
  [0]=>
  string(20) "C:\temp\hughTest.php"
  [1]=>
  string(1) "1"
  [2]=>
  string(1) "2"
  [3]=>
  string(1) "3"
}


     Hugh
Community
  • 1
  • 1
Hugh
  • 33
  • 4