0

I am trying to read a registry value on iis using the following script.

$shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$devenvpath=$shell->RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App\\Pathsfirefox.exe");

It doesn't work. It keeps telling me "Unable to open registry key". I am assuming this is a permissions issue but not sure. How can I get this to work.

Thanks for the help.

Brad
  • 159,648
  • 54
  • 349
  • 530
joeb
  • 777
  • 8
  • 28

2 Answers2

0

Perhaps its only a typo on your original post, but it looks to me as though there ought to be a "\" between "Paths" and "Firefox.exe" in that registry line.

$devenvpath=$shell->RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App\\Paths\\firefox.exe");
David W
  • 10,062
  • 34
  • 60
  • Nope still not working. It dies at the $shell line. I never get the echo statment below it to work try { $shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host"); echo "Never gets past the line above"; $response = $shell->RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\Path"); var_dump( $response ); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } – joeb Apr 21 '13 at 14:21
0

Finally got this working. I had to add the php extension for php_com_dotnet.dll. I did this inside php manager in IIS manager. Hope it helps someone else.

joeb
  • 777
  • 8
  • 28