Add vm_smb.bat
This commit is contained in:
parent
6d9221daad
commit
67a4b871f4
61
vm_smb.bat
Normal file
61
vm_smb.bat
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
REM -- Credential Management -- (Pre-register to avoid 'net use' hanging)
|
||||||
|
REM cmdkey /add:192.168.11.81 /user:zgqq /pass:1995826zgQ
|
||||||
|
REM cmdkey /add:192.168.11.50 /user:debian /pass:zgqq
|
||||||
|
|
||||||
|
REM -- Configuration Area --
|
||||||
|
REM Define total number of mappings
|
||||||
|
set MAPPINGS_COUNT=3
|
||||||
|
|
||||||
|
REM Mapping #1
|
||||||
|
set SHARE_1=\\192.168.11.50\Share01
|
||||||
|
set DRIVE_1=Z:
|
||||||
|
set USER_1=debian
|
||||||
|
set PASS_1=zgqq
|
||||||
|
|
||||||
|
REM Mapping #2
|
||||||
|
set SHARE_2=\\192.168.11.81\machines
|
||||||
|
set DRIVE_2=Y:
|
||||||
|
set USER_2=zgqq
|
||||||
|
set PASS_2=1995826zgQ
|
||||||
|
|
||||||
|
|
||||||
|
REM Mapping #3
|
||||||
|
set SHARE_3=\\192.168.11.81\machines_snap
|
||||||
|
set DRIVE_3=X:
|
||||||
|
set USER_3=zgqq
|
||||||
|
set PASS_3=1995826zgQ
|
||||||
|
|
||||||
|
|
||||||
|
REM To add more entries, copy the four lines above, change to SHARE_4...PASS_4, and increase MAPPINGS_COUNT accordingly
|
||||||
|
REM ----------
|
||||||
|
|
||||||
|
REM -- Main Loop: Iterate through mappings by index --
|
||||||
|
for /L %%i in (1,1,%MAPPINGS_COUNT%) do (
|
||||||
|
call :map_share "%%SHARE_%%i%%" "%%DRIVE_%%i%%" "%%USER_%%i%%" "%%PASS_%%i%%"
|
||||||
|
)
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:map_share
|
||||||
|
REM Parameters: %~1 = share, %~2 = drive, %~3 = user, %~4 = pass
|
||||||
|
set "share=%~1"
|
||||||
|
set "drive=%~2"
|
||||||
|
set "user=%~3"
|
||||||
|
set "pass=%~4"
|
||||||
|
|
||||||
|
REM First delete existing mapping (attempt regardless of existence)
|
||||||
|
net use %drive% /delete /y >nul 2>&1
|
||||||
|
|
||||||
|
REM Then create new mapping and make it persistent
|
||||||
|
net use %drive% "%share%" "%pass%" /user:"%user%" /persistent:yes >nul 2>&1
|
||||||
|
|
||||||
|
REM Print result with timestamp
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo [%date% %time%] Mount failed: %share% to %drive%
|
||||||
|
) else (
|
||||||
|
echo [%date% %time%] Mount successful: %share% to %drive%
|
||||||
|
)
|
||||||
|
|
||||||
|
goto :eof
|
||||||
Loading…
Reference in New Issue
Block a user