USB DRIVER HELP!!! (SOLVED)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joakim
Posts: 24
Joined: 07 Mar 2012 12:08

USB DRIVER HELP!!! (SOLVED)

#1 Post by joakim » 24 Jun 2012 14:03

TNX guys i soled it XD now i have made a simple thing to make you select the driver of your USB Drive, and it works Great =) im am soooo happy tnx guys :o now i only have to fix some things and its done =)

@echo off
color 0A
title USB Defender 2.5.1V
cls
echo ================================
echo Please Select an Drive to begin
echo ================================
echo.
echo.
echo Please wrigt down your USB drive (only the letter)
echo.
echo example: F: H: G: etc...
echo.
set /p "Drives=>"
echo.
echo.
Pause
cls

:Home
cls
echo =====================================================
echo = USB Security Tool 6.7.2V = "made by skillsa2=Lama_Disco=
echo =====================================================
echo.
echo DRIVER SELECTED = "%Drives%"
echo.
echo 1. Open Folder.(Works even if the folder are hidden)
echo.
echo 2. Unhide Folder.
echo.
echo 3. Hide Folder.
echo.
echo 4. Make a Folder.
echo.
echo 5. Hide the Folder %fna%. (Hides only new folders)
echo.
echo 6. Unide the Folder %fna%. (Unhides only new folders)
echo.
echo 7. Deltet Folder %fna%.
echo.
echo 8. Format drive. (Deletes all files and folders)
echo.
echo 9. See all hidden files.
echo.
echo 10. Exit
echo.
echo.
set /p "cho=>"

if %cho%==1 goto 1A
if %cho%==2 goto 2B
if %cho%==3 goto 3C
if %cho%==4 goto 4D
if %cho%==5 goto 5E
if %cho%==6 goto 6F
if %cho%==7 goto 7G
if %cho%==8 goto 8H
if %cho%==9 goto 9I
if %cho%==10 goto 10J

:1A
cls
IF EXIST Lock (goto pass1A) ELSE (md Lock)

:pass1A
set pass=12
echo Please Enter your Password.
echo.
echo.
set /p "ui=>"
if %ui%==%pass% (goto open1A)
echo.
echo.
cls
echo The password is not correct. Please try again
echo (make sure caps lock is NOT enabled).
echo.
echo.
pause
goto Home

:2B

cls
set pass=12
echo Please Enter your Password.
echo.
echo.
set /p "ui=>"
if %ui%==%pass% (goto Unhide2B)
echo.
echo.
cls
echo The password is not correct. Please try again
echo (Make sure caps lock is NOT enabled).
echo.
echo.
pause
goto Home

:3C

cls
Drives:
attrib Lock +s +h
goto Home

:4D
cls

echo Please Enter the name of the new folder.
echo.
echo.
set /p "fna=>"
md %fna%
echo The folder %fna% has been created!
echo.
echo.
pause
goto Home

:5GA


:8H
cls
set pass=12
echo Please Enter your Password.
echo.
echo.
set /p "ui=>"
if %ui%==%pass% (goto Delall8H)
echo.
echo.
cls
echo The password is not correct. Please try again
echo (make sure caps lock is NOT enabled).
echo.
echo.
pause
goto Home

:9I
cls
dir /ah
echo.
echo.
pause
goto Home

:7G
cls
set pass=12
echo Please Enter your Password.
echo.
echo.
set /p "ui=>"
if %ui%==%pass% (goto Delfol7G)
echo.
echo.
cls
echo The password is not correct. Please try again
echo (make sure caps lock is NOT enabled).
echo.
echo.
pause
goto Home

:6F
cls
%Drives%:
attrib %fna% -s -h

:5E
cls
%Drives%:
attrib %fna% +s +h
goto Home

:Delall8H
cls
format Drives

:Delfol7G
cls
del %fna% /F
echo.
echo.
pause
goto Home

:Unhide2B

cls
Drives
attrib Lock -s -h
goto Home

:open1A

cls
start Lock
goto Home

:10J
cls
exit
Last edited by joakim on 25 Jun 2012 05:19, edited 1 time in total.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: USB DRIVER HELP!!!

#2 Post by aGerman » 24 Jun 2012 14:14

You could always use relative pathes like \Spel. But if you're looking for the drive letter where the batch file is placed then apply %~d0.
Try that to display its content ...

Code: Select all

echo %~d0

... also have a look at the help message for call /?.

Regards
aGerman

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: USB DRIVER HELP!!!

#3 Post by Fawers » 24 Jun 2012 16:51

Following aGerman's stream of thought, you could start your file like this:

Code: Select all

@echo off
cd /d %~d0
set /a "pass=25 %% 13"

:menu
color 0A
::remaining code goes here

I used the module operator (%) to define the password because it's harder for other people to read (at least it's what I think).

A list with module operations resulting in 12 (1 < x < 100; 1 < y < 100)

Code: Select all

12 % 13 = 12
12 % 14 = 12
12 % 15 = 12
12 % 16 = 12
12 % 17 = 12
12 % 18 = 12
12 % 19 = 12
12 % 20 = 12
12 % 21 = 12
12 % 22 = 12
12 % 23 = 12
12 % 24 = 12
12 % 25 = 12
12 % 26 = 12
12 % 27 = 12
12 % 28 = 12
12 % 29 = 12
12 % 30 = 12
12 % 31 = 12
12 % 32 = 12
12 % 33 = 12
12 % 34 = 12
12 % 35 = 12
12 % 36 = 12
12 % 37 = 12
12 % 38 = 12
12 % 39 = 12
12 % 40 = 12
12 % 41 = 12
12 % 42 = 12
12 % 43 = 12
12 % 44 = 12
12 % 45 = 12
12 % 46 = 12
12 % 47 = 12
12 % 48 = 12
12 % 49 = 12
12 % 50 = 12
12 % 51 = 12
12 % 52 = 12
12 % 53 = 12
12 % 54 = 12
12 % 55 = 12
12 % 56 = 12
12 % 57 = 12
12 % 58 = 12
12 % 59 = 12
12 % 60 = 12
12 % 61 = 12
12 % 62 = 12
12 % 63 = 12
12 % 64 = 12
12 % 65 = 12
12 % 66 = 12
12 % 67 = 12
12 % 68 = 12
12 % 69 = 12
12 % 70 = 12
12 % 71 = 12
12 % 72 = 12
12 % 73 = 12
12 % 74 = 12
12 % 75 = 12
12 % 76 = 12
12 % 77 = 12
12 % 78 = 12
12 % 79 = 12
12 % 80 = 12
12 % 81 = 12
12 % 82 = 12
12 % 83 = 12
12 % 84 = 12
12 % 85 = 12
12 % 86 = 12
12 % 87 = 12
12 % 88 = 12
12 % 89 = 12
12 % 90 = 12
12 % 91 = 12
12 % 92 = 12
12 % 93 = 12
12 % 94 = 12
12 % 95 = 12
12 % 96 = 12
12 % 97 = 12
12 % 98 = 12
12 % 99 = 12
25 % 13 = 12
26 % 14 = 12
27 % 15 = 12
28 % 16 = 12
29 % 17 = 12
30 % 18 = 12
31 % 19 = 12
32 % 20 = 12
33 % 21 = 12
34 % 22 = 12
35 % 23 = 12
36 % 24 = 12
37 % 25 = 12
38 % 13 = 12
38 % 26 = 12
39 % 27 = 12
40 % 14 = 12
40 % 28 = 12
41 % 29 = 12
42 % 15 = 12
42 % 30 = 12
43 % 31 = 12
44 % 16 = 12
44 % 32 = 12
45 % 33 = 12
46 % 17 = 12
46 % 34 = 12
47 % 35 = 12
48 % 18 = 12
48 % 36 = 12
49 % 37 = 12
50 % 19 = 12
50 % 38 = 12
51 % 13 = 12
51 % 39 = 12
52 % 20 = 12
52 % 40 = 12
53 % 41 = 12
54 % 14 = 12
54 % 21 = 12
54 % 42 = 12
55 % 43 = 12
56 % 22 = 12
56 % 44 = 12
57 % 15 = 12
57 % 45 = 12
58 % 23 = 12
58 % 46 = 12
59 % 47 = 12
60 % 16 = 12
60 % 24 = 12
60 % 48 = 12
61 % 49 = 12
62 % 25 = 12
62 % 50 = 12
63 % 17 = 12
63 % 51 = 12
64 % 13 = 12
64 % 26 = 12
64 % 52 = 12
65 % 53 = 12
66 % 18 = 12
66 % 27 = 12
66 % 54 = 12
67 % 55 = 12
68 % 14 = 12
68 % 28 = 12
68 % 56 = 12
69 % 19 = 12
69 % 57 = 12
70 % 29 = 12
70 % 58 = 12
71 % 59 = 12
72 % 15 = 12
72 % 20 = 12
72 % 30 = 12
72 % 60 = 12
73 % 61 = 12
74 % 31 = 12
74 % 62 = 12
75 % 21 = 12
75 % 63 = 12
76 % 16 = 12
76 % 32 = 12
76 % 64 = 12
77 % 13 = 12
77 % 65 = 12
78 % 22 = 12
78 % 33 = 12
78 % 66 = 12
79 % 67 = 12
80 % 17 = 12
80 % 34 = 12
80 % 68 = 12
81 % 23 = 12
81 % 69 = 12
82 % 14 = 12
82 % 35 = 12
82 % 70 = 12
83 % 71 = 12
84 % 18 = 12
84 % 24 = 12
84 % 36 = 12
84 % 72 = 12
85 % 73 = 12
86 % 37 = 12
86 % 74 = 12
87 % 15 = 12
87 % 25 = 12
87 % 75 = 12
88 % 19 = 12
88 % 38 = 12
88 % 76 = 12
89 % 77 = 12
90 % 13 = 12
90 % 26 = 12
90 % 39 = 12
90 % 78 = 12
91 % 79 = 12
92 % 16 = 12
92 % 20 = 12
92 % 40 = 12
92 % 80 = 12
93 % 27 = 12
93 % 81 = 12
94 % 41 = 12
94 % 82 = 12
95 % 83 = 12
96 % 14 = 12
96 % 21 = 12
96 % 28 = 12
96 % 42 = 12
96 % 84 = 12
97 % 17 = 12
97 % 85 = 12
98 % 43 = 12
98 % 86 = 12
99 % 29 = 12
99 % 87 = 12

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: USB DRIVER HELP!!!

#4 Post by Aacini » 24 Jun 2012 17:59

Excuse me. I have not reviewed your program, I just focused on your question. Perhaps is this what you want?

Code: Select all

@echo off
set USB_DRIVE=none
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
   for %%c in (%%b) do (
      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (
         if %%d equ Removable (
            set USB_DRIVE=%%c
         )
      )
   )
)
echo The USB drive is: %USB_DRIVE%

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: USB DRIVER HELP!!!

#5 Post by Ed Dyreen » 24 Jun 2012 22:10

'
You lost me on this one Aacini,

Code: Select all

>for /F "tokens=1*" %a in ('fsutil fsinfo drives') do echo.%a,%b,%c
>echo.Stations:,A:\,%c
Stations:,A:\,%c


>fsutil fsinfo drivetype a:
a: - verwisselbaar station

>fsutil fsinfo drivetype b:
b: - verwisselbaar station

>fsutil fsinfo drivetype n:
n: - verwisselbaar station

'verwisselbaar station' is dutch for removeable drive
a: is a floppy drive,
b: is a virtual floppy,
n: is a smartcard.

I believe this way differentiates USB drives properly from other removeable drives.

First get all drives with mountvol

Code: Select all

set "$$=" &for /f "skip=16 tokens=1 delims=\ " %%? in ( 'mountVol.EXE' ) do ...
Next enumerate the regPath 'HKLM\SYSTEM\MountedDevices', something like

Code: Select all

for /f "tokens=2,4 delims=\    " %%a in (

   'reg.EXE query HKLM\SYSTEM\MountedDevices'

) do    set "$a=%%~a" &set "$b=%%~b" &( %StringInStringLHE_% $a, "!$drives.mounted!" ) &&if /i "!$b!" neq "!$b:470045004e0045005200490043005f0046004c004f005000500059005f00440052004900560045=!" (
   ::
   set "$drives.mounted.FLP=!$drives.mounted.FLP!, !$a!"
   set "$drives.mounted.RMV=!$drives.mounted.RMV!, !$a!"

) else    if /i "!$b!" neq "!$b:4300640052006f006d=!" (
   ::
   set  "$drives.mounted.CD=!$drives.mounted.CD!, !$a!"
   set "$drives.mounted.RMV=!$drives.mounted.RMV!, !$a!"

) else    if /i "!$b!" equ "!$b:5C003F00=!" (
   ::
   set  "$drives.mounted.HD=!$drives.mounted.HD!, !$a!"
)
I am being lazy, sorry. Have a look, function: ':§Drive.mounted ()' in file 'function.CMD'.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: USB DRIVER HELP!!!

#6 Post by foxidrive » 24 Jun 2012 22:40

Ed Dyreen wrote:You lost me on this one Aacini,


I added echo %%d %%c below

Code: Select all

@echo off
set USB_DRIVE=none
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
   for %%c in (%%b) do (
      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (

echo %%d %%c

         if %%d equ Removable (
            set USB_DRIVE=%%c
         )
      )
   )
)
echo The USB drive is: %USB_DRIVE%


and it prints this.

Fixed C:\
Fixed D:\
Fixed H:\
CD-ROM T:\
Remote/Network Z:\
The USB drive is: none


I plug in a USB drive and it prints this:
Fixed C:\
Fixed D:\
Removable E:\
Fixed H:\
CD-ROM T:\
Remote/Network Z:\
The USB drive is: E:\


It seems to work here.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: USB DRIVER HELP!!!

#7 Post by Aacini » 24 Jun 2012 22:54

A simple modification allows to omit A:\ and B:\ floppy drives:

Code: Select all

@echo off
set USB_DRIVE=none
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
   for %%c in (%%b) do (
      if %%c gtr C:\ (
         for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (
            if %%d equ Removable (
               set USB_DRIVE=%%c
            )
         )
      )
   )
)
echo The USB drive is: %USB_DRIVE%

Also, previous code get the last Removable drive; to get the first one, insert a GOTO EXIT command after the SET and place the :EXIT label after the first FOR ends.

We need OP's confirmation on these details... :|

Antonio

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: USB DRIVER HELP!!!

#8 Post by Ed Dyreen » 24 Jun 2012 23:44

'
Did I just discover yet another XP bug :x

Code: Select all

@echo off &ver

fsutil fsinfo drives

echo. &echo.test1
for /f "tokens=1*" %%a in ( 'echo.A:\ B:\ C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ M:\ N:\ O:\ P:\ X:\' ) do echo.a=%%a_ &echo.b=%%b_

echo. &echo.test2
for /f "tokens=1*" %%a in ('fsutil fsinfo drives') do echo.a=%%a_ &echo.b=%%b_

echo. &echo.test3
for /f "eol=@ delims=@" %%a in ('fsutil fsinfo drives') do echo.a=%%a_ &echo.b=%%b_

pause
exit

Code: Select all

Microsoft Windows XP [versie 5.1.2600]

Stations: A:\ B:\ C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ M:\ N:\ O:\ P:\ X:\

test1
a=A:\_
b=B:\ C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ M:\ N:\ O:\ P:\ X:\_

test2
a=Stations:_
b=A:\_

test3
a=Stations: A:\_
b=%b_
Druk op een toets om door te gaan. . .
But still, Aacini's detection method is based on removeable drives, is my floppy a USB ?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: USB DRIVER HELP!!!

#9 Post by foxidrive » 25 Jun 2012 00:35

Is your floppy drive an 8 inch or a 5 1/4 inch model? :D

That takes me back to the full height floppy drives I had on the Apple ][+ ...

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: USB DRIVER HELP!!! (SOLVED)

#10 Post by aGerman » 25 Jun 2012 11:34

It's kinda off topic since the TO runs the batch file from the USB drive (even if he changed his 1st post and removed that sentence) ...

Unfortunately Aacinis code isn't language independent also you need to run as administrator on Vista and newer versions. There's a WMIC solution that could help in that case

Code: Select all

@echo off &setlocal
set "removable=2"

for /f %%i in ('WMIC LOGICALDISK Where "DriveType='%removable%'" get DeviceID /Format:list') do (
  for /f %%j in ("%%i") do ECHO set "%%j\"
)

:: echo %DeviceID%

pause

The 2nd loop is for WMIC versions that return unicode ...

@Ed
I wonder if it would output your floppy :?:

Regards
aGerman

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: USB DRIVER HELP!!! (SOLVED)

#11 Post by Ed Dyreen » 25 Jun 2012 14:21

aGerman wrote:

Code: Select all

@echo off &setlocal
set "removable=2"

for /f %%i in ('WMIC LOGICALDISK Where "DriveType='%removable%'" get DeviceID /Format:list') do (
  for /f %%j in ("%%i") do ECHO set "%%j\"
)

:: echo %DeviceID%

pause

The 2nd loop is for WMIC versions that return unicode ...

@Ed
I wonder if it would output your floppy :?:

Regards
aGerman
It surely is removable.

Code: Select all

set "DeviceID=A:\"   << 3.5 inch
set "DeviceID=B:\"   << 3.5 inch
set "DeviceID=M:\"   << USB
set "DeviceID=N:\"   << USB
set "DeviceID=O:\"   << USB
set "DeviceID=P:\"   << USB
Druk op een toets om door te gaan. . .
It seems to detect both floppy's yes, I haven't tested but I assume it is possible to mount a USB to the drives A: or B: on a floppyless system.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: USB DRIVER HELP!!! (SOLVED)

#12 Post by aGerman » 25 Jun 2012 14:58

OK, I consulted the MSDN.

Code: Select all

DriveType

    Data type: uint32
    Access type: Read-only

    Numeric value that corresponds to the type of disk drive this logical disk represents.

    Value    Meaning
    0        Unknown
    1        No Root Directory
    2        Removable Disk
    3        Local Disk
    4        Network Drive
    5        Compact Disc
    6        RAM Disk

It seems that "Removable Disk" is the most suitable description for a floppy disk, isn't it.

Regards
aGerman

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: USB DRIVER HELP!!! (SOLVED)

#13 Post by Ed Dyreen » 25 Jun 2012 15:21

'
Hmm, I'll stick with my 'HKLM\SYSTEM\MountedDevices' solution. 8)
It is language independent and is able to differentiate a USB from a floppy.

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: USB DRIVER HELP!!! (SOLVED)

#14 Post by Liviu » 25 Jun 2012 16:25

Ed Dyreen wrote:I haven't tested but I assume it is possible to mount a USB to the drives A: or B: on a floppyless system.

It's even possible to mount a USB stick as drive B: on a single floppy system.

Liviu

Post Reply