Saved Bookmarks
| 1. |
Solve : how to check if a Drive is Fixed or Removable or a CD-DVD drive..???? |
|
Answer» Is there anyway to check in MS-DOS to see whether a certain Drive is Fixed or Removable or a CD-DVD drive..psinfo -d
is there any other way to do this though without the use of using and external downloaded app though..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.vbsOK, 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-Danybody have any IDEAS at all..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. 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..??@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 Hope this help you .. 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\"@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> anymore suggestions at all..??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? 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.. 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? |
|