I have these two commands
C:\Users\xyz\AppData\Local\Temp>WMIC LOGICALDISK where volumename="abc" get deviceid>%temp%/path.txt
which creates file path.txt with content:
DeviceID
F:
the file has lots of additional spaces which I have added in the above file^
I then use (although I know I could use the | char I am trying to avoid it) the command
C:\Users\xyz\AppData\Local\Temp>FINDSTR [:] path.txt>path2.txt
which gives the output F :
which is incredibly frustrating as I obviously just need the "F"/alphabetic char that would be in its position and store it in a variable.
Could someone please show me how to do this - or ultimately get the drive letter of a usb device using cmd only and store it in a variable?
I don't mind if it takes a lot of lines just no | char please or quote marks " :)
edit: it MUST be in command prompt and can be written line by line (no cop and paste commands) and I need the individual letter (eg. F:) by itself - stored in a variable or the clip board. and obviously, no pipe character or quote marks pls :)
No
|
char please :) I think you mean the pipe character|
(U+007C, Vertical Line)?Batch file (set a desired string to the
_volume
variable instead of my debugging valueElements
):Output:
.\SO\71753240.bat
Command prompt (copy and paste the following code snippet into an open
cmd.exe
window):Note that
wmic
output redirected to a file isUTF-16-BOM
: