1
I want to cd
to USB without specifying it because it changes its letter on every other computer.
1
I want to cd
to USB without specifying it because it changes its letter on every other computer.
2
I'm going to assume you are asking how to use "cd" using a volume label rather than a drive letter.
The trick is to query WMI to get the drive letter from a given label, save the result to a variable, and the pushd that variable path.
@ECHO OFF
FOR /F "tokens=1 skip=1" %%A IN ('WMIC logicaldisk where "volumename="%1"" get name') DO (
pushd %%A
goto fileend
)
:fileend
After the first result returned from WMIC, the loop will exit (Although, only one path should be returned anyways).
To use the script, save it as something like "cdlabel.cmd" anywhere in the PATH like System32, or in a easy-to-reach location. Then call it with the volume name as an argument like the following: "cdlabel GamingDrive"
any help with this https://postimg.org/image/hydpifkdl/
– mina nageh – 2016-08-25T14:53:58.127The code has to be run from a batch or cmd script file. You can try changing %%A to %A, but I doubt that will let you copy paste it into a cmd prompt. – CConard96 – 2016-08-25T19:30:47.453
did not work too https://postimg.org/image/kwvrmdhil/
– mina nageh – 2016-10-21T15:01:37.000As I said before, you cannot run this script by copy/pasting it directly into cmd. You have to use it as a script. – CConard96 – 2016-10-21T15:27:03.377
did not work too https://postimg.org/image/5pi2k282t/
– mina nageh – 2016-10-21T18:20:33.120