I have scripted MapName.bat to change name of a mapped drive.
Instead of seeing one of the following, I prefer to see (Drive Letter:) NewName:
Share Name on 'Comment Text (Computer Name) (Drive Letter:) Share Name on 'Computer Name (Comment Text) (Drive Letter:) (Drive Letter:) Share Name on 'Comment Text (Computer Name) (Drive Letter:) Share Name on 'Computer Name (Comment Text)The syntax for using MapName.bat is:
\[call\] MapName Drive NewName OK
Where:
Drive is the mapped drive letter. NewName is the name you wish to see. OK is a call directed environment variable that will contain a Y if the rename was successful, or a N if the rename failed.
Sample Usage:
MapName L: "Jerry's Laptop" Statuswill set the name of mapped drive letter L to Jerry's Laptop and set the Status environment variable to Y.
MapName.bat contains:
@echo off if \{%3\}==\{\} @echo Syntax MapName Drive NewName OK&goto :EOF setlocal set drv=%1 set drv=%drv:"=% set nn=%2 set nn=%nn:"=% set mn="%TEMP%\MapName_%RANDOM%.VBS" set er="%TEMP%\MapName_%RANDOM%.TMP" if exist %er% del /q %er% @echo Set oShell = CreateObject("Shell.Application")>%mn% @echo DRIVE = "%drv:~0,1%:\">>%mn% @echo oShell.NameSpace(DRIVE).Self.Name = "%nn%">>%mn% set OK=N call :quiet>%er% 2>&1 del /q %mn% call :sz %er% del /q %er% endlocal&set %3=%OK% goto :EOF :sz set /a size=%~z1 if %size% EQU 0 set OK=Y goto :EOF :quiet cscript //nologo %mn%
0 comments
Hide comments