php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30178 COM Object EnumNetworkDrives
Submitted: 2004-09-21 13:47 UTC Modified: 2004-09-22 12:03 UTC
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot Assigned:
Status: Not a bug Package: COM related
PHP Version: 5.0.1 OS: Windows 2000 SP4 5.00.2195
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot
New email:
PHP Version: OS:

 

 [2004-09-21 13:47 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Description:
------------
To enumerate network drives or printer connections, a COM function 'EnumNetworkDrives()' or 
'EnumPrinterConnections()'is used.
When I run my script with 'EnumNetworkDrives()' as an example, an exception is thrown. This exception is also thrown when using the function 'EnumPrinterConnections()'.


Reproduce code:
---------------
<?php

$network = new COM("WScript.Network");
$nd = $network -> EnumNetworkDrives();
for($i = 0; $nd -> Count(); $i += 2) {
  print $nd -> Item($i) . " " . $nd -> Item($i +1) . "\n";
}

?>

Expected result:
----------------
G: \\%SERVER%\%SHARE%
I: \\%SERVER%\%SHARE%
J: \\%SERVER%\%SHARE%
K: \\%SERVER%\%SHARE%
L: \\%SERVER%\%SHARE%
M: \\%SERVER%\%SHARE%

Actual result:
--------------
G: \\%SERVER%\%SHARE%
I: \\%SERVER%\%SHARE%
J: \\%SERVER%\%SHARE%
K: \\%SERVER%\%SHARE%
L: \\%SERVER%\%SHARE%
M: \\%SERVER%\%SHARE%
PHP Fatal error:  Uncaught exception 'com_exception' with message 'Source: Unknown
Description: Unknown' in C:\Scripts\php\drives.php:6
Stack trace:
#0 {main}
  thrown in C:\Scripts\php\drives.php on line 6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-22 12:03 UTC] wez@php.net
Your code looks broken, try this:

for($i = 0; $nd -> Count(); $i += 2) {
             ^
This means, keep going for all eternity, since nothing ever changes the count.

You want $i < $nd->Count()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC