Home / Microsoft / Microsoft DOS / how to check if a Drive is Fixed or Removable or a CD-DVD drive..???
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 4  All - (Bottom) Print
Author Topic: how to check if a Drive is Fixed or Removable or a CD-DVD drive..???  (Read 9360 times)
gumbaz
Topic Starter
Intermediate



Posts: 185


« on: August 01, 2007, 06:26:07 PM »

Is there anyway to check in MS-DOS to see whether a certain Drive is Fixed or Removable or a CD-DVD drive..???
IP logged
contrex
Guest
« 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%

IP logged
gumbaz
Topic Starter
Intermediate



Posts: 185


« 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..???
IP logged
ghostdog74
Mentor



Thanked: 26
Posts: 1,511


« 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
IP logged

gumbaz
Topic Starter
Intermediate



Posts: 185


« 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
IP logged
gumbaz
Topic Starter
Intermediate



Posts: 185


« Reply #5 on: August 03, 2007, 12:13:16 AM »

anybody have any ideas at all..???
IP logged
contrex
Guest
« 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.

IP logged
gumbaz
Topic Starter
Intermediate



Posts: 185


« 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..??
IP logged
ghostdog74
Mentor



Thanked: 26
Posts: 1,511


« 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
IP logged

Fen_Li
Beginner



Thanked: 2
Posts: 62

G-Smart thing Smart

« 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\"
IP logged

..Still Newbie KID..
gumbaz
Topic Starter
Intermediate



Posts: 185


« 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>
IP logged
gumbaz
Topic Starter
Intermediate



Posts: 185


« Reply #11 on: August 03, 2007, 10:02:38 PM »

anymore suggestions at all..??
IP logged
contrex
Guest
« 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?

IP logged
gumbaz
Topic Starter
Intermediate



Posts: 185


« 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..
IP logged
contrex
Guest
« 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?

IP logged
Pages: [1] 2 3 4  All - (Top) Print 
Home / Microsoft / Microsoft DOS / how to check if a Drive is Fixed or Removable or a CD-DVD drive..??? « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.112 seconds with 20 queries.