A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Windows 10 » Windows 10 Help Forum
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

What solution do you use to figure out what USB drive letter in a Windows scripted command?



 
 
Thread Tools Rate Thread Display Modes
  #1  
Old September 3rd 20, 05:51 PM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

I have a Run command that accesses a file on a USB stick.
o What trick to you employ to get the USB stick unique drive letter?

It's easy to obtain the _list_ of devices with drive letters, e.g.,
Win+R %comspec% /k wmic logicaldisk get caption,providername,drivetype,volumename
Win+R %comspec% /k wmic logicaldisk where drivetype=2 get deviceid, volumename, description
Win+R %comspec% /k for %i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @%i: 2nul && set/pz=%i nul
Win+R %comspec% /k for %a in (c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z do @vol %a 2&1 | find "drive"
etc.

But how do you ensure the command always uses the right drive letter??

Searching, one approach appears to be to permanently assign a drive letter:
o How to assign permanent letters to drives on Windows 10
https://www.windowscentral.com/how-assign-permanent-drive-letter-windows-10
https://www.groovypost.com/howto/assign-permanent-letter-removable-usb-drive-windows/

Another approach appears to be to change the drive letter on the fly:
o How to Change a Drive Letter in Windows
https://helpdeskgeek.com/how-to/change-drive-letter-windows/

Other approaches may be to make use of a customized batch script
to _find_ the drive letter (although these just _list_ them all):
o Here's how to get a USB drive letter from any drive
https://stackoverflow.com/questions/788554/find-usb-drive-letter
@echo off
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype
2^NUL`) do (
if %%l equ 2 (
echo %%i is a USB drive.
)
)

Note that identifying only and all (Type 2) USB drives is easy, but...
o What method do you use to ensure a command always gets the right USB drive?
--
Usenet allows purposefully helpful people to publicly share solutions.
  #2  
Old September 3rd 20, 07:08 PM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
R.Wieser
external usenet poster
 
Posts: 1,302
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

Arlen,

o What trick to you employ to get the USB stick unique drive letter?

....
But how do you ensure the command always uses the right drive letter??


Easy : A for loop going over all drive letters like the one in your fourth
example, but combined with a check if a certain file/folder name exists on
the target drive.

Regards,
Rudy Wieser



  #3  
Old September 5th 20, 10:11 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

SOLVED

Here's a tutorial for how I solved the stated problem set just now.
(As always, please improve so that all benefit from every action.)

a. The goal is to maintain a pc-specific system log by typing on any PC:
Win+R syslog
b. Which executes whatever command is set up in the AppPaths key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\syslog.exe
DEFAULT == (command to edit a syslog file on a USB drive of any letter)
c. Such that the USB stick holding the logs can be plugged into any PC
and the AppPaths command will figure out the machine & drive letter.
[DRIVE_LETTER_#]:\software\machine#\syslog.txt

1. Create a batch file to edit the syslog & place the batch file in
any location where you feel it naturally belongs, e.g., on machine1:

@echo off
:: Edit the system log (stored on a USB stick) for this PC.
:: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-identify-drive-letters
:: C:\app\os\bat\syslog.bat
@for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if exist %%a:\software\ set SW_DRIVE=%%a
:: Modify the comamnd below to edit your system log file
:: @notepad %SW_DRIVE%:\software\machine1\syslog.txt
@vim %SW_DRIVE%:\software\machine1\syslog.txt

2. On machine1, create a new AppPaths key for easy Win+R access:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
a. Create a new key named "syslog.exe"
b. Point it to the batch file: default = C:\app\os\bat\syslog.bat

Note: The AppPaths key name must end with ".exe" but otherwise,
it can be any name that isn't already in use, or that doesn't
already point to an executable file that is in your PATH.
(Of course, whatever name you give it will be the command!)

3. Test that your new AppPaths key works to edit the syslog file:
Win+R syslog

No matter which drive letter the USB stick is currently,
this should find your uniquely named syslog filespec.
%SW_DRIVE%:\software\machine#\syslog.txt

Note: If the filespec doesn't exist, an error will result.
Note: It's not a good idea to have the same path on multiple USB sticks.

4. If desired, optionally create a shortcut to that batch file
(so that you add multiple easily-found methods to run it)
which you can then place in your menus or on your taskbar.

Notice there is no "pin to taskbar" option when you right click
on the shortcut; to resolve that, please see this related tutorial:
o Please follow this cut-and-paste tutorial to get batch command
shortcuts working perfectly on Windows
https://groups.google.com/forum/#!topic/microsoft.public.windowsxp.general/1PzeGP4KMTU

HINT: Add %comspec% /K" to the shortcut TARGET:
FROM TARGET = C:\app\os\bat\syslog.bat
TO TARGET = %comspec% /K C:\app\os\bat\syslog.bat
After that change, you can now right-click "Pin to taskbar".

Please see this related tutorial to create a custom icon.
o Tutorial for creating custom Windows icons from screenshots using only Irfanview freeware
https://groups.google.com/forum/#!topic/alt.comp.freeware/qeHbJySBp0M

Please see this solution for creation of custom cascade menus:
o Why does anyone bother to install Classic Shell on Windows
if all they want is the WinXP accordion-style sliding cascade Start Menu?
https://groups.google.com/forum/#!topic/alt.comp.freeware/u0YHG35cE-E

Please see this related solution if the filespec is on Android:
o Does freeware exist on Windows that will mount (as a drive letter) Android connected via USB as MTP?
https://groups.google.com/forum/#!topic/alt.comp.freeware/TaIlIMK2Nuw

In summary, this tutorial describes one way to create a "syslog"
command which can be run on any of your PCs so that you can edit
a syslog.txt file specific for that PC which is stored on a USB
stick that is plugged into that PC (and whose drive letter will
be figured out, on the fly, by the syslog command you created).

As always, please improve so that all benefit from every action.
--
Usenet allows users to tap into help and advice from around the world.
  #4  
Old September 5th 20, 10:34 AM posted to alt.comp.os.windows-10
R.Wieser
external usenet poster
 
Posts: 1,302
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

Arlen,

SOLVED

....
@for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
exist %%a:\software\ set SW_DRIVE=%%a


Well done. :-)

How does it feel, having solved it yourself (instead of us just having given
it to you) ? I bet it feels good. I know it always does to me.

Regards,
Rudy Wieser



  #5  
Old September 5th 20, 05:45 PM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

UPDATE:

To always add actionable value in each post, in the freeware group,
MikeS added purposefully helpful cut-and-paste
actionable suggestions for downloading the Microsoft tool from
elsewhere on the net (sans the need for the Microsoft SDK):

o How to obtain the USBview.exe tool to view details about Windows hardware USB ports
https://groups.google.com/forum/#!topic/alt.comp.freeware/71MMJQWWjgk

To save others the effort, I downloaded each of those suggested
more easily obtained alternatives, & ran a cursory (but obligatory)
check, as follows:

1. This is the 64-bit binary from the Microsoft SDK that I installed:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/

Name: usbview.exe
Size: 815048 bytes (795 KiB)
SHA256: 4EB5DADFA86CCFFE209A050E20A526BEEB7C3A116229CF0465 DE4278B3875080

C:\app\archiver\7zip\7z.exe l "C:\app\os\sdk\Debuggers\x64\usbview.exe" | findstr CPU
o CPU = x64

C:\app\os\sysinternals\sigcheck.exe "C:\app\os\sdk\Debuggers\x64\usbview.exe" | findstr MachineType
o MachineType: 64-bit

Doublecheck by right-clicking on the exe "Properties" "Compatibility"
Temporarily check the Compatibility Mode option of
[x]Run this program in compatibility mode for:
[Windows Vista] == if this is the first entry, then your executable is 64-bit
[Windows Vista (Service Pack 1)
[Windows Vista (Service Pack 2)
[Windows 7]
[Windows 8]

Note: If Windows XP is on the list, then your executable is 32-bit,
where you will likely also see even older Windows versions listed:
[Windows 95]
[Windows 98 / Windows Me]
[Windows XP (Service Pack 2)
[Windows XP (Service Pack 3)

2. This is the 32-bit binary from that Microsoft SDK I installed yesterday:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/

Name: usbview.exe
Size: 676808 bytes (660 KiB)
SHA256: 5240369DE615B076F7DE548523CDDA51D720078D130985B177 E00F3C05C4EB96

C:\app\archiver\7zip\7z.exe l "C:\app\os\sdk\Debuggers\x86\usbview.exe" | findstr CPU
o CPU = x86

C:\app\os\sysinternals\sigcheck.exe "C:\app\os\sdk\Debuggers\x86\usbview.exe" | findstr MachineType
o MachineType: 32-bit

3. This is the result from your helpful activesilicon suggestion:
https://www.activesilicon.com/wp-content/uploads/USB-devices-browser-Microsoft.zip

Name: usbview.exe
Size: 823848 bytes (804 KiB)
SHA256: 82EBF5D101EB1E0E9C59C83EB75B70F63E3FB45CD8621E9CB6 2C5BE46E758762

C:\app\archiver\7zip\7z.exe l "C:\tmp\activesilicon\usbview.exe" | findstr CPU
o CPU = x64

C:\app\os\sysinternals\sigcheck.exe "C:\tmp\activesilicon\usbview.exe" | findstr MachineType
o MachineType: 64-bit

4. This is the result from your helpful ftdichip suggestion:
https://www.ftdichip.com/Support/Utilities/usbview.zip

Name: usbview.exe
Size: 84808 bytes (82 KiB)
SHA256: 5D6AC13598E825D92D872601CB46F0BAA9E0F171E38FE14FE1 248A1FF366C289

C:\app\archiver\7zip\7z.exe l "C:\tmp\ftdichip\usbview.exe" | findstr CPU
o CPU = x86

C:\app\os\sysinternals\sigcheck.exe "C:\tmp\ftdichip\usbview\usbview.exe" | findstr MachineType
o MachineType: 32-bit

Note the Microsoft SDK and the Microsoft ADK both install in the same location!
That is, both the Microsoft ADK & SDK install to the same locale
(i.e., the [Browse] button is grayed out so they're both the same.)

The ADK was previously installed earlier this week for this tutorial:
o Expert help requested for removing UAC user account control task scheduler syntax
https://groups.google.com/forum/#!topic/alt.comp.microsoft.windows/7wpgdNscZNA

Here is where you can get the Microsoft SDK:
o https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/

Here is where you can get the Microsoft ADK:
o https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install
--
Every tutorial to Usenet should strive to be actionable, i.e., more than just pretty words.
  #6  
Old September 5th 20, 06:20 PM posted to alt.comp.os.windows-10
Big Al[_5_]
external usenet poster
 
Posts: 1,588
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On 9/5/20 5:34 AM, this is what R.Wieser wrote:
Arlen,

SOLVED

...
@for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if
exist %%a:\software\ set SW_DRIVE=%%a


Well done. :-)

How does it feel, having solved it yourself (instead of us just having given
it to you) ? I bet it feels good. I know it always does to me.

Regards,
Rudy Wieser



Great. Just hope you don't have ?:\software on two drives.

  #7  
Old September 6th 20, 01:16 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On Sat, 5 Sep 2020 13:20:58 -0400, Big Al wrote:

Just hope you don't have ?:\software on two drives.


We have to choose _something_ to identify the drive.

I would have loved to identify the volume label, or, better yet, the device
serial number, but I didn't find any examples on the net that were even
close.

For finding the serial number, Poutnik proposed a Nirsoft utility, which
not only easily reports the serial number, but also (if you're an admin),
allows simply right-click change of the drive letter.
https://www.nirsoft.net/utils/usb_devices_view.html
https://www.nirsoft.net/utils/usbdeview-x64.zip
Name: USBDeview.exe
Size: 189816 bytes (185 KiB)
SHA256: 0C93E5C815BA258750CE4762A4CDB8FA746B05D525BD463ED6 DBE243CD790FB2

Running USBDeview and comparing to the Microsoft and the Sieber usbview,
this Nirsoft utility is the same but different in a whole bunch of ways.

It presents the USB data in a columnar fashion, one row per USB device,
where my USB stick in question showed up as a named drive letter, a given
serial number, etc.

In summary, we have to key off of "something" to identify the drive:
a. The serial number of the USB device
b. The volume name of the USB device
c. The label of the USB device
d. The mount point (aka Drive Letter) of the USB device
e. A filespec on the USB device
etc.

Of all these things, I prefer the "serial number" as we can presume that's
"most" unique (for some value of uniqueness); but I don't even know how to
programmatically obtain the serial number of a mounted USB volume.
https://hatsoffsecurity.com/2014/06/05/usb-forensics-pt-1-serial-number/

Googling, I see these commands report serial numbers of all drives
but strangely enough, they each report a _different_ serial number
for the same USB device!
o Win+R %comspec% /k vol j:
o Win+R %comspec% /k wmic diskdrive get Model, Name, InterfaceType, SerialNumber

In summary, one solution to avoid the problem you speak of where
two USB drives may have the same filespec, is to modify the
script to identify the USB stick by it's "unique" serial number
--
Usenet allows purposefully helpful people to suggest & share ideas.
  #8  
Old September 4th 20, 08:58 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
JJ[_14_]
external usenet poster
 
Posts: 46
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On Thu, 3 Sep 2020 16:51:29 -0000 (UTC), Arlen Holder wrote:

Note that identifying only and all (Type 2) USB drives is easy, but...
o What method do you use to ensure a command always gets the right USB drive?


For me who sometime still use virtual floppy disks, the `MediaType` WMI
field is also needed to provide more accurate result. Because drive type `2`
(Removable Disk type) is also used for floppy drives and likely
LS-120/ZIP/JAZZ drives too. FYI, if it's a thumb drive including SD cards,
the media type would be `12` (Fixed Disk).
  #9  
Old September 4th 20, 10:37 PM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
MajorLanGod
external usenet poster
 
Posts: 13
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

JJ wrote in
:

On Thu, 3 Sep 2020 16:51:29 -0000 (UTC), Arlen Holder wrote:

Note that identifying only and all (Type 2) USB drives is easy,
but... o What method do you use to ensure a command always gets the
right USB drive?


For me who sometime still use virtual floppy disks, the `MediaType`
WMI field is also needed to provide more accurate result. Because
drive type `2` (Removable Disk type) is also used for floppy drives
and likely LS-120/ZIP/JAZZ drives too. FYI, if it's a thumb drive
including SD cards, the media type would be `12` (Fixed Disk).


Back when I was playing with a lot of different USB drives, I reserved a
drive letter for each specific USB drive. Windows will assign the next
currently available drive letter whenever a USB drive is mounted. I just
used Disk Management to change that letter to the one I wanted. Granted,
once one gets to 20 different USB drives or so this method falls apart,
although I never tried to use two letters to identify a drive, I don't
thing Windows will allow that.

Windows also allows one to Name each drive, and I assume there is a way
to examine that name without too much trouble.
  #10  
Old September 5th 20, 07:43 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On Fri, 04 Sep 2020 21:37:04 GMT, MajorLanGod wrote:

I reserved a drive letter for each specific USB drive.


Thank you for your purposefully helpful advice, where I'm well aware
that I'm asking for a solution to a problem that can have many solutions,
but where any one good solution is useful for everyone to benefit from.

The option to force the drive letter is certainly one option I've considered.
o How to Assign a Persistent Drive Letter to a USB Drive in Windows
https://www.howtogeek.com/96298/assign-a-static-drive-letter-to-a-usb-drive-in-windows-7/

But I'm seeking something more flexibly elegant, in that it should
ascertain the drive letter on its own, in order to edit files on
that drive letter.

Note that my sole purpose is to maintain a system log by typing:
Win+R syslog

Where the AppPaths key in the registry must edit that file:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\syslog.exe
DEFAULT == (anything that edits the syslog file on an external USB drive)

The syslog file is stored on an external USB drive (for safety).
Where the trick is figuring out the path to that syslog file.
And where, for each PC, that syslog file will be unique.
But the same USB flash drive will be used for all PCs.

Windows also allows one to Name each drive, and I assume there is a way
to examine that name without too much trouble.


Thanks for your purposefully helpful advice.
There are a bunch of approaches, each with its own pros and cons.
I'm slowly working through them as we speak.

For example, the Windows "vol" command tells us the volume name
if we know the drive letter.
C:\ vol X:
Volume in drive X is FOOBAR
Volume Serial Number is 2521-FEB4

On the other hand, if you know the volume, you can find the drive:
@echo off
:: Given the volume name, it reports the drive letter
setlocal
set vName=%1
if [%1]==[] set /p vName=Enter volume to search for:
set n=0
set ltrs=ABCDEFGHIJKLMNOPQRSTUVWXYZ
:Loop
call set ltr=%%ltrs:~%n%,1%%
set /a n +=1
vol %ltr%: 2nul|find /i " %vname%"nul||if %n% lss 26 goto :loop
if %n% equ 26 (set "ltr="
echo No matching volume label found.
) else (echo Volume %1 is drive %ltr%
endlocal & set ltr=%ltr%
pause

Without knowing either, this will show all the removable USB drives:
@Echo off
setlocal enabledelayedexpansion
Set "USB="
REM get removable loaded drives:
for /f "tokens=1-5" %%a in (
'wmic logicaldisk list brief'
) do if %%b Equ 2 if %%d gtr 0 Set USB=!USB! %%a
Echo:Usb removable drives:%USB%
EndLocal&Set USB=%USB:~1%&Goto :Eof

Without knowing either, this outputs the last removable drive:
@echo off
:: https://stackoverflow.com/questions/...letter-changes
:: Drivetypes
:: 0=Unknown
:: 1=No Root Directory
:: 2=Removable(USB,Firewire)
:: 3=Local Disk (Internal Hard Drive)
:: 4=Network Drive(\\Server\share\)
:: 5=Compact Disk (CD DVD)
:: 6=Ram Disk
for /f "tokens=2 delims==" %%d in ('wmic logicaldisk where "drivetype=2"
get name /format:value') do set driveletter= %%d
echo %driveletter%
pause

However, given the point is to easily edit a system log file on an external
USB drive, I may make use of the fact that unique file and folder names
will exist on that external USB drive.

For example, this script looks promising given the USB stick has a unique
folder and file that I'm attempting to edit (even as the USB drive letter
won't be unique as it can change each time it's inserted into the PC):

@echo Find a drive that has a root folder titled "software".
:: https://docs.microsoft.com/en-us/win...-drive-letters
@for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @if exist %%a:\software\ set SW_DRIVE=%%a
@echo The "software" root folder is on drive: %SW_DRIVE%
:: @dir %SW_DRIVE%:\software /w
@vim %SW_DRIVE%:\software\machine1\syslog.txt
--
Note that my sole purpose is to maintain a system log by typing:
Win+R syslog

Where the AppPaths key in the registry should edit that file:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\syslog.exe
DEFAULT == (anything that edits the syslog file on an external USB drive)

The syslog file is stored on an external USB drive (for safety).
Where the trick is figuring out the path to that syslog file.
And where, for each PC, that syslog file will be unique.
But the same USB flash drive will be used for all PCs.
  #11  
Old September 5th 20, 10:25 AM posted to alt.comp.os.windows-10
R.Wieser
external usenet poster
 
Posts: 1,302
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

MajorLanGod,

Back when I was playing with a lot of different USB drives,
I reserved a drive letter for each specific USB drive.


I have a thumbdrive for a rather specific function, and I did the same for
it. CD drive at X:, thumbdrive at Y:

The problem with that solution is that the OP has not given us enough
information to be able to conclude if hes using his thumbdrive on a single,
or on multiple 'puters. And in the last case, if he has admin rights on
them (IIRC needed to change or assign a fixed letter to a drive).

Windows also allows one to Name each drive,


I assume you mean the drive's label.

and I assume there is a way to examine that name without
too much trouble.


Don't bet on it. Notice the newsgroups he has crossposted his question in.

Regards,
Rudy Wieser



  #12  
Old September 5th 20, 06:06 PM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On Fri, 04 Sep 2020 21:37:04 GMT, MajorLanGod wrote:

I assume there is a way
to examine that name without too much trouble.


Thank you MajorLanGod for your purposefully helpful suggestions.

The first experiment that worked for me was the aforementioned
script that identifies the flash drive by filespec.

However, to your point, it certainly would be nice if someone
posts a script that solves the problem using the volume name.

Bear in mind, I also will be solving this problem for Linux.

Given these three newsgroups were added for explicit purposes:
a. alt.msdos.bat (Windows batch experts)
b. alt.comp.os.windows-10 (Windows 10 experts, no dejagoogle archives)
c. alt.comp.microsoft.windows (for the dejagoogle archives)

You'll note I did not ask this question of Linux experts,
even as the setup I'm devising _also_ will work on Linux
(given all my machines are generally set up as dual boot).

Hence, I simplified filespecs to limit this question to Windows.
o And I simplified the explanation of the overall problem set.

I limited the question to Windows for the purpose of this thread.
o To clarify, there is one flash card, and multiple dual-boot machines.

To that point, when I plug in the USB stick to any of my computers,
(only some of which are Windows, while others are booted to Linux)
what's "unique" about that USB stick is the "volume name", and
the file hierarchy on that specific system software USB stick.

For example, the USB stick variables are threefold:
o %SW_DRIVE%:\%OS%\software\%MACHINE_#%\syslog.txt
1. The software drive can change upon every insertion.
2. The OS will be either Linux or Windows at any given time.
3. The machine will be any number of dual-boot PCs.

To your purposefully helpful suggestion of identifying the flash drive by
its volume name, that was certainly possible (and viable).

If anyone has a batch script that replaces the one I proposed,
which uses the volume name instead of a filespec to identify the drive,
that would be a very useful actionable addition to this thread.
--
A tutorial, if it's not actionable, is just a pretty story.
  #13  
Old September 5th 20, 07:23 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

JJ wrote:
On Thu, 3 Sep 2020 16:51:29 -0000 (UTC), Arlen Holder wrote:
Note that identifying only and all (Type 2) USB drives is easy, but...
o What method do you use to ensure a command always gets the right USB drive?


For me who sometime still use virtual floppy disks, the `MediaType` WMI
field is also needed to provide more accurate result. Because drive type `2`
(Removable Disk type) is also used for floppy drives and likely
LS-120/ZIP/JAZZ drives too. FYI, if it's a thumb drive including SD cards,
the media type would be `12` (Fixed Disk).


Thumb drives can have RMB=0 or RMB=1.

At one time, the thumb drives were pretty consistently
using only one of those values. Then some Sony ones showed up
with the other value. When the sticks get large (32GB),
the designers start having second thoughts about how
"volatile" they are and whether they rate a "fixed" kind
of attribute.

https://www.uwe-sieber.de/usbstick_e.html

*******

And this tool, gives some control over letter assignments.
It was mainly intended for situations where one subsystems
letter assignment practices, were stomping on another
subsystem. And this utility was intended to provide
some separation between the two (so there would be fewer
surprises).

https://www.uwe-sieber.de/usbdlm_e.html

Paul
  #14  
Old September 5th 20, 08:39 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On Sat, 05 Sep 2020 02:23:12 -0400, Paul wrote:

And this tool, gives some control over letter assignments.


Hi Paul,

Did you know there is a "USB Device Viewer" in Microsoft Windows?
o I didn't (until I just tried it, as shown by my log file below).

1. Go to the Microsoft Windows 10 SDK page:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/

2. Click on the [DOWNLOAD THE INSTALLER] button on that page.
That will download the Windows SDK tools installer, version 10.0.19041.1
Name: winsdksetup.exe
Size: 1354464 bytes (1322 KiB)
SHA256: D53F651370F87484B78622E30DFB1A41920B501E4041035771 C0D785561F47D5

3. Run that "winsdksetup.exe" Windows Software Development Kit installer:
Page1: Specify Location (Browse to any location you like) [Next]
Page2: Windows Kits Privacy (Send anonymous usage data = no) [Next]
Page3: License Agreement [Accept]
Page4: Select the features you want to install [Install]
[_]Windows Performance Toolkit
[x]Debugging Tools for Windows (449.3MB)
[_]Application Verifier For Windows
[_].NET Framework 4.8 Software Development Kit
[_]Windows App Certification Kit
[_]Windows IP Over USB
[_]MSI Tools
[_]Windows SDK Signing Tools for Desktop Apps
[_]Windows SDK for UWP Managed Apps
[_]Windows SDK for UWP C++ Apps
[_]Windows SDK for UWP Appls Localization
[_]Windows SDK for Desktop C++ x86 Apps
[_]Windows SDK for Desktop C++ amd64 Apps
[_]Windows SDK for Desktop C++ arm Apps
[_]Windows SDK for Desktop C++ arm64 Apps

4. If you selected the default paths, notice these two files:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\usbview.exe
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\usbview.exe.config
(The config is so that the usbview.exe works without .NET 3.5 appaently.)

5. Copy those two files to where you feel they should belong, e.g.,
c:\app\os\windows_sdk\usbview.exe
c:\app\os\windows_sdk\usbview.exe.config

You are copying them because they're the only files you really wanted
for the purpose of running the Microsoft Windows USB File Viewer tool.

6. If desired, delete the SDK just installed (as you copied what you wanted):
Win+R control [View by: Category] Programs uninstall a program

Note: I have both of these where the latter was just installed:
[Windows Assessment and Deployment Kit - Windows 10]
[Windows Software Development Kit - Windows 10.0.1904.1]

7. Doubleclick on the "usbview.exe" USB Device Viewer where you may be
surprised at how many USB ports show up (many you don't normally see).

The reason that there are so many items in the tree is that USB ports
need to be able to support multiple USB versions.
https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/

The tree shows which ports have devices connected and which don't.
a. Ports with connected devices show a blue and red USB icon.
b. Ports not currently in use show a blue USB icon.
c. Adjacent to the ports in use is a generic name on the right.

8. You can click around to "explore" the USB map of your computer.
For example, plug and unplug a USB stick & watch what changes.

In short, the Microsoft Windows USB File Viewer (usbview.exe) is a
neat tool for exploring all the USB ports on your Windows PC.
--
Usenet is a wonderfully public way to discuss technical items of interest.


  #15  
Old September 5th 20, 07:51 PM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

Arlen Holder wrote:
On Sat, 05 Sep 2020 02:23:12 -0400, Paul wrote:

And this tool, gives some control over letter assignments.


Hi Paul,

Did you know there is a "USB Device Viewer" in Microsoft Windows?
o I didn't (until I just tried it, as shown by my log file below).

1. Go to the Microsoft Windows 10 SDK page:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/

2. Click on the [DOWNLOAD THE INSTALLER] button on that page.
That will download the Windows SDK tools installer, version 10.0.19041.1
Name: winsdksetup.exe
Size: 1354464 bytes (1322 KiB)
SHA256: D53F651370F87484B78622E30DFB1A41920B501E4041035771 C0D785561F47D5

3. Run that "winsdksetup.exe" Windows Software Development Kit installer:
Page1: Specify Location (Browse to any location you like) [Next]
Page2: Windows Kits Privacy (Send anonymous usage data = no) [Next]
Page3: License Agreement [Accept]
Page4: Select the features you want to install [Install]
[_]Windows Performance Toolkit
[x]Debugging Tools for Windows (449.3MB)
[_]Application Verifier For Windows
[_].NET Framework 4.8 Software Development Kit
[_]Windows App Certification Kit
[_]Windows IP Over USB
[_]MSI Tools
[_]Windows SDK Signing Tools for Desktop Apps
[_]Windows SDK for UWP Managed Apps
[_]Windows SDK for UWP C++ Apps
[_]Windows SDK for UWP Appls Localization
[_]Windows SDK for Desktop C++ x86 Apps
[_]Windows SDK for Desktop C++ amd64 Apps
[_]Windows SDK for Desktop C++ arm Apps
[_]Windows SDK for Desktop C++ arm64 Apps

4. If you selected the default paths, notice these two files:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\usbview.exe
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\usbview.exe.config
(The config is so that the usbview.exe works without .NET 3.5 appaently.)

5. Copy those two files to where you feel they should belong, e.g.,
c:\app\os\windows_sdk\usbview.exe
c:\app\os\windows_sdk\usbview.exe.config

You are copying them because they're the only files you really wanted
for the purpose of running the Microsoft Windows USB File Viewer tool.

6. If desired, delete the SDK just installed (as you copied what you wanted):
Win+R control [View by: Category] Programs uninstall a program

Note: I have both of these where the latter was just installed:
[Windows Assessment and Deployment Kit - Windows 10]
[Windows Software Development Kit - Windows 10.0.1904.1]

7. Doubleclick on the "usbview.exe" USB Device Viewer where you may be
surprised at how many USB ports show up (many you don't normally see).

The reason that there are so many items in the tree is that USB ports
need to be able to support multiple USB versions.
https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/

The tree shows which ports have devices connected and which don't.
a. Ports with connected devices show a blue and red USB icon.
b. Ports not currently in use show a blue USB icon.
c. Adjacent to the ports in use is a generic name on the right.

8. You can click around to "explore" the USB map of your computer.
For example, plug and unplug a USB stick & watch what changes.

In short, the Microsoft Windows USB File Viewer (usbview.exe) is a
neat tool for exploring all the USB ports on your Windows PC.


Microsoft usbview.exe superceded by
Microsoft uvcview2.exe (Win7 SDK) superceded by
https://www.uwe-sieber.de/usbtreeview_e.html

The latter preferred because you can actually find it
when you need a copy. Has added USB3 functions.

The usbview has an obvious name.

The UVC stands for USB Video Class, which is a standard class
driver for webcam like devices. But it just continues to display
config space information like the other one.

Paul
 




Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off






All times are GMT +1. The time now is 09:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.