#1 25.10.05 15:12
Как переименовать сетевой диск из консоли?
грабли вот в чем, юзерам при входе в сеть мапятся сетевые диски
net use p: \\путь
в результате в "моём компьютере" добавляется диск р, который имеет метку: "username на такойто такойто путь" в общем метку очень и очень кривую, её можно изменить если щёлкнуть правым мышом на нём и выбрать "переименовать", но хочу все это загнать в скрипт. Пытался заюзать команду label [disk:[label] - к сетевым дискам не работает (
Как консольными командами сменить метку сетевого диска ?
(Операционка 2000)
Offline
#2 25.10.05 16:43
Re: Как переименовать сетевой диск из консоли?
Лови:
1.
[HKEY_CURRENT_USER\Network\p]
"RemotePath"="\\\\server3\\video"
"UserName"=""
"ProviderName"="Microsoft Windows Network"
"ProviderType"=dword:00020000
"ConnectionType"=dword:00000001
"DeferFlags"=dword:00000004
2.
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##server3#video]
"BaseClass"="Drive"
"_CommentFromDesktopINI"=""
"_LabelFromDesktopINI"=""
"_LabelFromReg"="p"
Offline
#3 25.10.05 16:48
Re: Как переименовать сетевой диск из консоли?
Дальше: скрипт для logon.cmd:
RenUse "New Name" DriveLetter: \\ComputerName\ShareName [Options]
where:
"New Name" will display as New Name (DriveLetter:).
DriveLetter: is the drive letter you are mapping. Previous mappings will be replaced.
\\ComputerName\ShareName is the standard net use syntax.
[Options] are any additional net use switches that you want.
Processing and Requirements
Windows NT, Windows 9X, Windows ME
"New Name" is ignored, even though it is a required parameter.
Any previous DriveLetter: mapping is deleted and DriveLetter: is mapped to the \\ComputerName\ShareName [Options].
Windows 2000
The Windows 2000 Resource Kit REG.EXE program is required for writing New Name to the registry.
The conversion of New Name to Unicode takes a few seconds, more if New Name is long.
Windows XP
REG.EXE is installed when Windows XP is installed.
Windows 2000 and Windows XP
The client must have permission to write their own registry hive.
Any previous DriveLetter: mapping is deleted and DriveLetter: is mapped to the \\ComputerName\ShareName [Options].
The following characters may NOT be used in New Name:
" % & : ; < = > ^ | ~
RenUse.bat contains:
@echo off
setlocal
if {%3}=={} @echo Syntax: RenUse Name Drive: Server\Share [Options] &goto done
if not "%OS%"=="Windows_NT" goto W9x
set arg=%1
set arg=%arg:"=%
set drive=%2
set drivel=%drive:~0,1%
if "%drivel%:" NEQ "%drive%" @echo Syntax: RenUse Name Drive: Server\Share [Options] &goto done
for /f "Tokens=5,6 Delims=[. " %%i in ('ver') do @set osv=%%i.%%j
if "%osv:~0,3%" LSS "5.0" goto w9x
if "%osv:~0,3%" GTR "5.0" goto wxp
set uni=!21#23$24'27(28)29*2A+2B,2C-2D.2E/2F030131232333434535636737838939?3F@40A41B42C43D44E45F46G47H48I49J4AK4BL4CM4DN4EO4FP50Q51R52S53T54U55V56W57X58Y59Z5A[5B\5C]5D_5F`60a61b62c63d64e65f66g67h68i69j6Ak6Bl6Cm6Dn6Eo6Fp70q71r72s73t74u75v76w77x78y79z7A{7B}7D~20~20
set cachefill=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000##
set cache=
set /a cachecnt=0
if exist %drive% net use %drive% /D>nul 2>&1
net use %drive% %3 %4 %5 %6 %7 %8>nul 2>&1
set arg=%arg: =~%
set file=%TEMP%\Renuse.tmp
set file="%file:"=%"
if exist %file% del /q %file%
for /l %%i in (0,3,249) do call :build %%i
set /a cnt=0
goto :parse
:build
for /f "Tokens=*" %%j in ('@echo %%uni:~%1^,3%%') do @echo %%j>>%file%
goto :EOF
:parse
for /f "Tokens=*" %%n in ('@echo %%arg:~%cnt%^,1%%') do set char=%%n
if "%char%" EQU "ECHO is on." goto end
set /a cnt=%cnt% + 1
for /f "Tokens=*" %%t in ('findstr /B /L /C:%char% %file%') do set unit="%%t"
if %unit% EQU "" set unit="~20"
set cache=%cache%%unit:~2,2%00
set /a cachecnt=%cachecnt% + 4
set cachefill=%cachefill:0000##=##%
if %cachecnt% GEQ 128 goto end
goto parse
:wxp
if exist %drive% net use %drive% /D>nul 2>&1
set key=%3
set key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\%key:\=#%
reg ADD %key% /v _LabelFromReg /d "%arg%" /f>nul 2>&1
:wxpqry
reg QUERY %key% /v _LabelFromReg>nul 2>&1
if %ERRORLEVEL% EQU 1 goto :wxpqry
net use %drive% %3 %4 %5 %6 %7 %8>nul 2>&1
endlocal
goto :EOF
:w9x
if exist %2 net use %2 /D>nul 2>&1
net use %2 %3 %4 %5 %6 %7 %8>nul 2>&1
endlocal
goto :EOF
:end
set cachefill=%cachefill:##=%
set cache=%cache%%cachefill%
:query
set key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints\%drivel%\_LabelFromReg
reg QUERY %key% /v Cache>nul 2>&1
if %ERRORLEVEL% EQU 1 goto :query
reg QUERY %key% /v Version>nul 2>&1
if %ERRORLEVEL% EQU 1 goto :query
reg ADD %key% /v Cache /t REG_BINARY /d %cache% /f>nul 2>&1
reg ADD %key% /v Version /t REG_DWORD /d 3 /f>nul 2>&1
:done
Endlocal
Offline
#4 25.10.05 16:48
Re: Как переименовать сетевой диск из консоли?
И еще для автоматики:
If you wish to map and automatically set My Computer to display ShareName (DriveLetter:), use RenShare.bat in a logon script. The syntax is:
RenShare DriveLetter: \\ComputerName\ShareName [Options]
where:
DriveLetter: is the drive letter you are mapping. Previous mappings will be replaced.
\\ComputerName\ShareName is the standard net use syntax.
[Options] are any additional net use switches that you want.
Processing and Requirements
Windows NT, Windows 9X, Windows ME
Any previous DriveLetter: mapping is deleted and DriveLetter: is mapped to the \\ComputerName\ShareName [Options].
Windows 2000
The Windows 2000 Resource Kit REG.EXE program is required for writing ShareName to the registry.
The conversion of ShareName to Unicode takes a few seconds.
Windows XP
REG.EXE is installed when Windows XP is installed.
Windows 2000 and Windows XP
The client must have permission to write their own registry hive.
Any previous DriveLetter: mapping is deleted and DriveLetter: is mapped to the \\ComputerName\ShareName [Options].
Any trailing $ is omiited from the ShareName (DriveLetter:) display.
RenShare.bat contains:
@echo off
setlocal
if {%2}=={} @echo Syntax: RenShare Drive: Server\Share [Options] &goto done
if not "%OS%"=="Windows_NT" goto W9x
set drive=%1
set drivel=%drive:~0,1%
if "%drivel%:" NEQ "%drive%" @echo Syntax: RenShare Drive: Server\Share [Options] &goto done
set arg=%2
set arg=%arg:"=%##
set arg=%arg:$##=%
set arg=%arg:##=%
for /f "Tokens=2 Delims=\" %%a in ('@echo %arg%') do set arg=%%a
for /f "Tokens=5,6 Delims=[. " %%i in ('ver') do @set osv=%%i.%%j
if "%osv:~0,3%" LSS "5.0" goto w9x
if "%osv:~0,3%" GTR "5.0" goto wxp
set uni=!21#23$24'27(28)29*2A+2B,2C-2D.2E/2F030131232333434535636737838939?3F@40A41B42C43D44E45F46G47H48I49J4AK4BL4CM4DN4EO4FP50Q51R52S53T54U55V56W57X58Y59Z5A[5B\5C]5D_5F`60a61b62c63d64e65f66g67h68i69j6Ak6Bl6Cm6Dn6Eo6Fp70q71r72s73t74u75v76w77x78y79z7A{7B}7D~20~20
set cachefill=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000##
set cache=
set /a cachecnt=0
if exist %drive% net use %drive% /D>nul 2>&1
net use %drive% %2 %3 %4 %5 %6 %7 %8>nul 2>&1
set arg=%arg: =~%
set file=%TEMP%\Renuse.tmp
set file="%file:"=%"
if exist %file% del /q %file%
for /l %%i in (0,3,249) do call :build %%i
set /a cnt=0
goto :parse
:build
for /f "Tokens=*" %%j in ('@echo %%uni:~%1^,3%%') do @echo %%j>>%file%
goto :EOF
:parse
for /f "Tokens=*" %%n in ('@echo %%arg:~%cnt%^,1%%') do set char=%%n
if "%char%" EQU "ECHO is on." goto end
set /a cnt=%cnt% + 1
for /f "Tokens=*" %%t in ('findstr /B /L /C:%char% %file%') do set unit="%%t"
if %unit% EQU "" set unit="~20"
set cache=%cache%%unit:~2,2%00
set /a cachecnt=%cachecnt% + 4
set cachefill=%cachefill:0000##=##%
if %cachecnt% GEQ 128 goto end
goto parse
:wxp
if exist %drive% net use %drive% /D>nul 2>&1
set key=%2
set key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\%key:\=#%
reg ADD %key% /v _LabelFromReg /d "%arg%" /f>nul 2>&1
:wxpqry
reg QUERY %key% /v _LabelFromReg>nul 2>&1
if %ERRORLEVEL% EQU 1 goto :wxpqry
net use %drive% %2 %3 %4 %5 %6 %7 %8>nul 2>&1
endlocal
goto :EOF
:w9x
if exist %1 net use %1 /D>nul 2>&1
net use %1 %2 %3 %4 %5 %6 %7 %8>nul 2>&1
endlocal
goto :EOF
:end
set cachefill=%cachefill:##=%
set cache=%cache%%cachefill%
:query
set key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints\%drivel%\_LabelFromReg
reg QUERY %key% /v Cache>nul 2>&1
if %ERRORLEVEL% EQU 1 goto :query
reg QUERY %key% /v Version>nul 2>&1
if %ERRORLEVEL% EQU 1 goto :query
reg ADD %key% /v Cache /t REG_BINARY /d %cache% /f>nul 2>&1
reg ADD %key% /v Version /t REG_DWORD /d 3 /f>nul 2>&1
:done
Endlocal
Offline
#5 25.10.05 16:50
Re: Как переименовать сетевой диск из консоли?
Offline

