exploder Posted June 29, 2008 Share Posted June 29, 2008 ??? I am looking for a way to find out what the hard disk drive letters are on windows computers on the network. I need to keep up with the hard drive free space on these machines which I can do with the "freediskspace()" function, but I need to first find out how many drives the computers have - some have a C drive only, some have C and D, others have C E and F. I need to know how to get the drive letters and make sure they are hard drives and not cdroms or mapped network drives. I think vb script has something like "("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")" but I need to do it in php if at all possible. Thanks in advance for any assistance. Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/ Share on other sites More sharing options...
br0ken Posted June 29, 2008 Share Posted June 29, 2008 Would this work for you? for($i = 65; $i <= 90; $i++) { $size = numf(@filesize(chr($i).":")); if ($size > 0) echo $size."<br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-577173 Share on other sites More sharing options...
.josh Posted June 29, 2008 Share Posted June 29, 2008 Someone in the manual gave an example of how to list all drives, free space, total space and percentage free. I suppose you can find out whether it's a cdrom drive or not by virtue of the numbers the code produces, but AFAIK there's no way to figure out whether it may be a mapped network drive or not. Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-577178 Share on other sites More sharing options...
exploder Posted June 30, 2008 Author Share Posted June 30, 2008 Thanks for the replies broken and crayon....Im surprised I haven't seen this before. I tried it and it looks like it will do the trick, I just need to get it to run through a list of machine hostnames. I intend to run it as a cron job or scheduled task and generate text files, then just parse the text files with the web page, probably load the page quicker. I found a Pear package called WinDrives but it looks like it would have to be executed from a windows machine, still nice though. I guess we can mark this as complete, thanks. Just curious - Why does this for loop use 65 to 90 ? Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-578469 Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 He's passing it through chr() which returns the character from the value that you pass to it. I think 65-90 is like A-Z or something. Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-578477 Share on other sites More sharing options...
br0ken Posted June 30, 2008 Share Posted June 30, 2008 He's passing it through chr() which returns the character from the value that you pass to it. I think 65-90 is like A-Z or something. That's exactly right Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-578483 Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 He's passing it through chr() which returns the character from the value that you pass to it. I think 65-90 is like A-Z or something. That's exactly right Yeah, I knew what it was doing, but I was too lazy to actually count the numbers to see if it was actually the right amount of letters, lol. Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-578490 Share on other sites More sharing options...
exploder Posted June 30, 2008 Author Share Posted June 30, 2008 Oh ok.... chr() On the machines I have tested it on so far, mapped network drives do not show up which is fine, I don't want those. I hope that's the way it's intended to work... Mike Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-578502 Share on other sites More sharing options...
.josh Posted June 30, 2008 Share Posted June 30, 2008 Oh ok.... chr() On the machines I have tested it on so far, mapped network drives do not show up which is fine, I don't want those. I hope that's the way it's intended to work... Mike Earlier I told you that I didn't know if there was a way to tell if it was a mapped network drive or not, but I just read one of the notes for the link I gave earlier: Note: This function will not work on remote files as the file to be examined must be accessible via the server's filesystem. So yes, that is working as intended. Quote Link to comment https://forums.phpfreaks.com/topic/112407-solved-show-hard-disk-drives-on-windows-computers/#findComment-578511 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.