ยินดีต้อนรับ สู่ Thailand Generating Batch Scripts

Blogger นี้จัดทำขึ้นมาเพื่อแบ่งปัน Batch Scripts ที่ผู้เขียนได้จัดทำขึ้นเพื่อใช้ในงานต่างๆ ทั้งการจัดการให้ระบบ Computer สามารถทำงานได้ด้วยความถูกต้อง

พร้อมทั้งเพิ่มความสะดวก สำหรับการจัดการดูแลรวมถึงการประยุกต์ใช้งานต่างๆได้ หวังเพียงให้โลกของเรามีการแบ่งปันเอื้อเฟื้อซึ่งกันและกัน ขอให้ประโยชน์สุขก์จงเกิดแก่มนุษย์โลกทุกท่าน

(เพื่อต่อยอดให้เกิดการแบ่งปันแก่มนุษย์โลกสืบต่อไป)

วันอาทิตย์ที่ 14 กันยายน พ.ศ. 2557

MAPDrives SCripts With Show Drive Letters First and Rename Drive Label with ShareName

:: START SCRIPTS ::
@echo off&setLocal EnableDelayedExpansion
:: All Drive L,M,N,O,P,Q,R,S,T,U,V,W,X,Y
:: Set your Drive Need to Map Drive
set _drivemap=n,s,t,u,w,x,y
call :sharepth1
set _maplist=%Temp%\sharepath1.txt
:stmap
:: Remove All Map drives
net use * /delete /y >nul
:: Show Drive Letters First
set _hkcuexp=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
call :shwdir1
:: Map Drive and Rename Drive Label
for /f "tokens=1,2 delims=:" %%a in (!_maplist!) do (
set _uncpth=%%b
set _str=!_uncpth: =!
set _regpth=!_uncpth:\=#!
set _labelpth="%_hkcuexp%\MountPoints2\!_regpth!"
call :cntchar !_str!
for %%i in (!_drivemap!) do (
if /i %%a==%%i net use %%a: "!_uncpth!">nul
if /i %%a==%%i call set _sname=%%_str:~!_lch!%%
if /i %%a==%%i reg add !_labelpth! /v _LabelFromReg /t REG_SZ /d "!_sname!" /f>nul
)
)
del /q /f !_maplist!
exit /b

:shwdir1
set _dchk=0
for /f "Tokens=*" %%i in ('reg query %_hkcuexp% ^|FIND /I /C "ShowDriveLettersFirst"') do set _dchk=%%i
if %_dchk%==0 reg add %_hkcuexp% /v ShowDriveLettersFirst /t REG_DWORD /d 00000004>nul
goto:eof

:cntchar
set _strx=%1
set _cha=\
set i=-1
set n=0
:nextchar
    set /a i+=1
    set c=!_strx:~%i%,1!
    if "!c!"=="" goto endline
        set /a n+=1
    if "!c!"=="!_cha!" set _lch=!n!
    goto nextchar
:endline
goto:eof

:: END SCRIPTS ::

:sharepth1
>"%temp%\sharepath1.txt" echo L:\\<SHARE_SERVER1>\<SHARE_PATH1>
>>"%temp%\sharepath1.txt" echo M:\\<SHARE_SERVER1>\<SHARE_PATH2>
>>"%temp%\sharepath1.txt" echo N:\\<SHARE_SERVER1>\<SHARE_PATH3>
>>"%temp%\sharepath1.txt" echo O:\\<SHARE_SERVER1>\<SHARE_PATH4>
>>"%temp%\sharepath1.txt" echo P:\\<SHARE_SERVER1>\<SHARE_PATH5>
>>"%temp%\sharepath1.txt" echo Q:\\<SHARE_SERVER1>\<SHARE_PATH6>
>>"%temp%\sharepath1.txt" echo R:\\<SHARE_SERVER2>\<SHARE_PATH7>
>>"%temp%\sharepath1.txt" echo S:\\<SHARE_SERVER2>\<SHARE_PATH8>
>>"%temp%\sharepath1.txt" echo T:\\<SHARE_SERVER2>\<SHARE_PATH9>
>>"%temp%\sharepath1.txt" echo U:\\<SHARE_SERVER2>\<SHARE_PATH10>
>>"%temp%\sharepath1.txt" echo V:\\<SHARE_SERVER2>\<SHARE_PATH11>
>>"%temp%\sharepath1.txt" echo W:\\<SHARE_SERVER3>\<SHARE_PATH12>
>>"%temp%\sharepath1.txt" echo X:\\<SHARE_SERVER3>\<SHARE_PATH13>
>>"%temp%\sharepath1.txt" echo Y:\\<SHARE_SERVER3>\<SHARE_PATH14>
goto:eof

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

ผู้ติดตาม