Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

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

瀏覽次數:865 次
跳到第一則未讀訊息

Arlen Holder

未讀,
2020年9月3日 中午12:51:312020/9/3
收件者:
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: 2>nul && 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.

R.Wieser

未讀,
2020年9月3日 下午2:08:202020/9/3
收件者:
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



JJ

未讀,
2020年9月4日 凌晨3:58:492020/9/4
收件者:
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).

MajorLanGod

未讀,
2020年9月4日 下午5:37:072020/9/4
收件者:
JJ <jj4p...@gmail.com> wrote in
news:nx2ytaviku6f$.18ount5z...@40tude.net:
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.

Paul

未讀,
2020年9月5日 凌晨2:23:172020/9/5
收件者:
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

Arlen Holder

未讀,
2020年9月5日 凌晨2:43:472020/9/5
收件者:
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%: 2>nul|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/19103950/running-batch-file-from-usb-drive-when-drive-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/windows-hardware/manufacture/desktop/winpe-identify-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.

Arlen Holder

未讀,
2020年9月5日 凌晨3:39:212020/9/5
收件者:
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: D53F651370F87484B78622E30DFB1A41920B501E4041035771C0D785561F47D5

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.


Arlen Holder

未讀,
2020年9月5日 清晨5:11:092020/9/5
收件者:
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.

Arlen Holder

未讀,
2020年9月5日 中午12:45:202020/9/5
收件者:
UPDATE:

To always add actionable value in each post, in the freeware group,
MikeS <Mi...@fred.com> 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: 4EB5DADFA86CCFFE209A050E20A526BEEB7C3A116229CF0465DE4278B3875080

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: 5240369DE615B076F7DE548523CDDA51D720078D130985B177E00F3C05C4EB96

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: 82EBF5D101EB1E0E9C59C83EB75B70F63E3FB45CD8621E9CB62C5BE46E758762

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: 5D6AC13598E825D92D872601CB46F0BAA9E0F171E38FE14FE1248A1FF366C289

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.

Arlen Holder

未讀,
2020年9月5日 下午1:06:112020/9/5
收件者:
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.

Paul

未讀,
2020年9月5日 下午2:51:562020/9/5
收件者:
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

Arlen Holder

未讀,
2020年9月5日 下午3:40:442020/9/5
收件者:
On Sat, 05 Sep 2020 14:51:50 -0400, Paul wrote:

> 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.

Hi Paul,

Even though I had never heard of this "usbview" utility until now...

You convinced me that your suggested USBview is _better_ than the MS one!
o Thank you for being purposefully helpful in your suggestions & advice.

One test alone was sufficient for you to make me into a believer:
<https://i.postimg.cc/2SSN3bKR/usbview01.jpg>
a. The Sieber USBview provides far more useful readable output
b. Than does the Microsoft USBview from which it's based upon

For one example, the drive letter of the USB stick is clearly shown
o Where, in the Microsoft USBview, the drive letter is not clearly shown

I should clarify that when I was seeking a solution to the now solved
"Win+R > syslog" problem set, I was "hoping" this previously unknown-to-me
Microsoft usbview tool would have allowed me to use it on the command line,
to identify the USB drive containing the syslog.txt file for each PC.

Since your Sieber usbview works from the command line, it might identify
the USB drive letter based on either the volume name or a filespec.

Downloading your helpfully suggested "USB Device Tree Viewer V3.4.0"
<https://www.uwe-sieber.de/files/UsbTreeView_x64.zip>
Name: UsbTreeView.exe
Size: 608128 bytes (593 KiB)
SHA256: EE4CD7994A74BE955BDD1F2612960C68685C3CF4FEAAB6F787DC619E9AD6C0F5

The readme contains useful information which may be of use in a batch
file to identify the USB stick volume and/or filespec to the sylog file.

UsbTreeView [/R=filename] [/X=filename] [/O=filename] [/L[n]=logfile]

/R=filename write (silently) a text report to filename
/X=filename write (silently) an XML report to filename
/O=filename open an XML report from filename
/L[n]=logfile write a logfile for debugging
n is the optional loglevel, default is 3, max is 5;
sample: /L4=C:\temp\UsbTreeView.log

One thing I instantly see about this Sieber usbview versus the native
Microsoft usbview is that the drive letter of the USB stick is reported.
<https://i.postimg.cc/2SSN3bKR/usbview01.jpg>

Thank you for your purposefully helpful useful technical advice.
--
Usenet is a wonderfully shared public way to discuss technical solutions.

Arlen Holder

未讀,
2020年9月5日 晚上8:16:532020/9/5
收件者:
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: 0C93E5C815BA258750CE4762A4CDB8FA746B05D525BD463ED6DBE243CD790FB2

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.

Arlen Holder

未讀,
2020年9月6日 清晨6:31:022020/9/6
收件者:
SIDE NOTE:

In an attempt at assessing which of the two is most useful for my needs, I
was monitoring USB comings and goings using the Nirsoft USBDeview utility
Poutnik suggested alongside the Sieber USBTreeView utility Paul suggested.

My goal was to use them for a day or two, and choose the one I like best.

On one monitor I had both Nirsoft USBDeview & Sieber USBTreeView running,
and wouldn't you know it. At some point in time, I heard the classic USB
disconnect and then re-connect sounds, and glanced at the USB viewers.

In Paul's suggested Sieber USBTreeView, the line for the USB mouse was
green, and no other line seemed highlighted. So it's the USB mouse!

Note: At first, I only saw the green because I missed the red, but when I
tested it by pulling out the cord, it goes red first and then green when
reconnected and then within a second or so, it goes back to transparent.

That's a neat hardware debugging tool for intermittent USB disconnects!

Given that works so well, if you have an intermittent issue with USB
devices disconnecting momentarily, then I would suggest keeping Paul's
suggested Sieber USBTreeView running, so that, when it happens, you can
visually see which device is disconnecting and then reconnecting.
--
The great thing about solving one problem is it usually solves even more.

Loren

未讀,
2020年9月9日 晚上11:55:532020/9/9
收件者:
On Sat, 5 Sep 2020 19:40:43 -0000 (UTC), Arlen Holder wrote:

>On Sat, 05 Sep 2020 14:51:50 -0400, Paul wrote:
>
>> 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.
>
>Hi Paul,
>
>Even though I had never heard of this "usbview" utility until now...
>
>You convinced me that your suggested USBview is _better_ than the MS one!
>o Thank you for being purposefully helpful in your suggestions & advice.
>
>One test alone was sufficient for you to make me into a believer:
> <https://i.postimg.cc/2SSN3bKR/usbview01.jpg>
>a. The Sieber USBview provides far more useful readable output
>b. Than does the Microsoft USBview from which it's based upon
>
>For one example, the drive letter of the USB stick is clearly shown
>o Where, in the Microsoft USBview, the drive letter is not clearly shown


Another similar tool is USBDeview from NirSoft. It gives the USB
device view in table form which can be saved. If you scroll down a bit
it has command line options to Check if a device is
connected/disconnected or enabled/disabled

http://www.nirsoft.net/utils/usb_devices_view.html


Loren

Arlen Holder

未讀,
2020年9月30日 晚上10:24:442020/9/30
收件者:
Update:

Given the Sieber USBTreeView tool does so many good things...
o One of which is "safely remove" & "restart device"

As shown in this screenshot I just took for that purpose just now:
o <https://i.postimg.cc/RZJGLwY8/usbview03.jpg>

If we can, perhaps, script those two USBTreeView commands...
o Then, perhaps, maybe, just maybe, we can solve this problem set:

o eject flash drive?, by T (date September 20, 2020)
<https://groups.google.com/forum/#!topic/alt.msdos.batch/NfFLp6d6fWo>

Where the command may be similar to that which we already use for volumes:
o Win+R > mountall
o Win+R > unmountall
As explained in more detail in that thread.

In summary, perhaps we can script the USBTreeView commands...
o So that we gain the ability to run these two commands
1. mountusb
2. unmountusb
--
Sometimes you need just a little bit of syntactical help to get it working.
0 則新訊息