I am currently learning how to do batch scripting. Would I like to do is make a batch file that looks for the volume name of a drive and then once it find its renames the drive letter to another letter.
Example
Plug in usb drive: OMG (E:)
Script finds volume label OMG
Renames (E:) to (O:)
End results is
OMG (O:)
I would like this to work somehow, because I am going to be using it to set up multi computers at once. I am just trying to make the install process a bit smoother on things.
Thanks
Eric
look for volume name, change drive letter
Moderator: DosItHelp
Re: look for volume name, change drive letter
You may not even need to do that at all. I would rather you explain what you are trying because there may be a better way to do it.
Re: look for volume name, change drive letter
What I would like to do is Move a certain file, well its a VPN connection file. So in the script I would like the file be moved from the USB with a copy and paste command. so from O:\rasphone.pbk copy file from file path to. C:\Users\OMG\AppData\Roaming\Microsoft\Network\Connections\Pbk
Re: look for volume name, change drive letter
You however have to find the drive letter of you USB device first. Once you know it the changing of the letter would be pointless.
Untested:
Remove ECHO and PAUSE if drive letter and path are displayed correctly.
Regards
aGerman
Untested:
Code: Select all
@echo off &setlocal
for /f "tokens=1* delims==" %%i in (
'wmic logicaldisk where "VolumeName='OMG'" get DeviceID /value'
) do for /f %%k in ("%%j") do set "drive=%%k"
ECHO copy /y "%drive%\rasphone.pbk" "%appdata%\Microsoft\Network\Connections\Pbk\"
PAUSE
Remove ECHO and PAUSE if drive letter and path are displayed correctly.
Regards
aGerman
Re: look for volume name, change drive letter
I will give it shot in a little bit here today and let you know the results of this.
Thanks in advance
*EDIT*
I tested the above code and it shows the drive and the location correctly. It just doesn't copy/paste the the file in the folder location.
Thanks in advance
*EDIT*
I tested the above code and it shows the drive and the location correctly. It just doesn't copy/paste the the file in the folder location.
Re: look for volume name, change drive letter
aGerman wrote:Remove ECHO and PAUSE if drive letter and path are displayed correctly.
Re: look for volume name, change drive letter
aGerman wrote:aGerman wrote:Remove ECHO and PAUSE if drive letter and path are displayed correctly.
Reading is FUN!
Re: look for volume name, change drive letter
Squashman wrote:Reading is FUN!
I didn't know echo and pause would cause it to stop it from copying over. Like I said before, I am learning on how to do this. sorry for not understand how it all works.