I hope someone can help :)
I'm trying
- to get the output of a WMIC query into a variable
- to manipulate this variable by deleting the last char (colon)
- to reuse this remaining char in my script
This is the line which generates the value I need to work with:
for /f "skip=1" %%A in ('wmic logicaldisk where "Description='Removable Disk'" get name') do
Usually, the output looks like this:
E:
Now I need to cut this variable to get the driveletter "E" only, which I need to reuse in my script.
I found this threat which I expected to be the solution for my problem too. Unfortunately this doesn't work for me since the output is completely empty applying this.
I think I'm doing something wrong when writing the output the %%A into a variable.
My code currently looks like this:
@ECHO OFF
for /f "skip=1" %%A in ('wmic logicaldisk where "Description='Removable Disk'" get name') do (
echo.%%A
set drive=%%A
set drive=%drive:~0,-1%
echo.%drive%
)
Output of this code is:
E:
:*:
:*:
Does somebody know what I'm doing wrong? :)
Thank you in advance for any help!