I'm trying to do a simple little CLI that requires the user to specify a drive letter. now i could just ask them for the letrer, but i thought it'd be cool if they could choose from a list. now i don't think there is any real directory called 'My Computer' that i can look in, but there must be some way to get the list........

this isn't a biggie if you don't know, but any ideas are welcome.

    Well i found HKLM\SYSTEM\MountedDevices, but on my machine that lists two drives that aren't there (G: and H:, which have never been there) and also i'm not sure how to access the registry from PHP. So, my only conclusion is that this is impossible. Yes i have searched the forums, and yes i have googled. no luck.

      well,

      the thing is called SECURITY.

      How would you feel if somebody could list your harddrive through a web-interface?

      J

        I'm sure there's a way, but it would only be able to get the drive letters present on the server. Is this the desired result?

          this is for a command line script, not a web interface. i thought i clearly stated that in the first post.

          [edit] Yes Lord, that's exactly what i'm looking for[/edit]

            -- my bad & apologies => Bedtime I suppose! --

              Okay, what version of Windows? Do you have the DRVSPACE utility on there? I know using DRVSPACE /LIST will do this, but I think that's a fairly old utility. I'll keep looking

                i'm running XP, and drvspace is not in the path, so i'm suposing i don't have it.

                  Ok, I found something for you. It's probably going to take some regex work to pull out what you want, but here's what you need:

                  There's a partition utility in XP called diskpart. You will need to make a seperate script to run against this utility. I created C:\disks.txt. Inside that file, there's one line:

                  list volume

                  Then from the command line, run diskpart /s C:\disks.txt

                  Should return output like this:

                    Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
                    ----------  ---  -----------  -----  ----------  -------  ---------  --------
                    Volume 0     E                       CD-ROM          0 B
                    Volume 1     F                       CD-ROM          0 B
                    Volume 2     G   THPS4 CD2    CDFS   DVD-ROM      684 MB
                    Volume 3     D   Data         NTFS   Partition    112 GB  Healthy
                    Volume 4                             Partition     38 GB  Healthy
                    Volume 5     C                NTFS   Partition     93 GB  Healthy    System
                    Volume 6                             Partition   1907 MB  Healthy
                    Volume 7                             Partition     70 GB  Healthy

                  Then you can apply your regex to pull drive letters. Seems kinda like a hassle, but was the best I could find

                    Thanks a lot Lord! 🙂 i really appreciate, ill hack together something later tonight and tell you how it goes. 🙂

                      This is kinda crude, but should work. I'm thinking something like this is going to be pretty custom anyway, so just tweak it to work for ya.

                      <?php
                      exec("diskpart /s C:\\disks.txt", $ret);
                      for($i=0;$i<=6;$i++) {
                         // get rid of headers and un-needed crap
                         unset($ret[$i]);
                      }
                      $drives = array();
                      foreach($ret as $r) {
                         // split on whitespace
                         $split = preg_split("/[\s]+/",$r);
                         if(strlen($split[3]) == 1) {
                            // should be 3rd element
                            // if it's only one letter, we'll take it
                            $drives[] = $split[3];
                         }
                      }  
                      sort($drives); reset($drives); ?>

                      Yeah, and the board ditches double slashes, so the actual exec command should be
                      exec("diskpart /s C:\disks.txt", $ret);

                        actually i'm just usin preg_match_all:

                        exec('diskpart /s disk.txt', $arr);
                        $ret = implode("\n",$arr);
                        preg_match_all('#^\s+Volume \d+\s{5}([A-Z]).*$#m', $ret, $matches);
                        $drives = $matches[1];

                        but thanks for that anyways 🙂

                        [edit]OR you could just use single-quotes 😉[/edit]

                          Originally posted by Moonglobe

                          [edit]OR you could just use single-quotes 😉[/edit]

                          Nah, I'll just use *nix :p

                            hah! i'm thinking of totally trashing windows now that i've found out that my video drivers don't support directx 9.... even after an update to the most recent ones. so no more Halo, no more point for windows....

                              Well the core XFree86 team disbanded last week, so it's kinda uncertain at this point what will happen with Linux desktop development.

                                and i was not informed ....... why? 🙁

                                btw nice harddrives 😉

                                  from the comments it would appear that they weren't doing much more than hold everyone back in the first place, but as fas as i'm concerned that's just heresay.... i have near no knowledge on the subject.

                                    Well, I really know as much as you guys, but from everything I gather, these guys haven't been doing much of anything on XFree86 for a long time now. It's become such a big community project anymore, there hasn't been a need for their intervention. So, at first, I thought the disbanding was no big deal, but after reading more, the question keeps coming up of who the successor is going to be. Like XFree86 is completely done. So, I really don't know what's going to happen. I assume it will will remain a community project, and that it will continue to run the Linux GUI until something just seems better.

                                      Write a Reply...