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

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. Commented May 23, 2014 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. Commented May 23, 2014 at 21:46
  • I've also tried it both under an administrative shell and without. Same result. Commented May 23, 2014 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. stackoverflow.com/questions/4234581/… Commented May 23, 2014 at 22:13

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.