ik gebruik ook zo'n script, iets uitgebreider. Deze bat file save je in C windows root. En een run.vbs file in je opstarten folder en klaar.
Wel makkelijk inderdaad, bij een boot mount deze gewoon je shared folders, dit gaat onzichtbaar zonder window dus.
Je kan zelf aangeven welke folders je wil. Je hoeft alleen je nas ip in te voeren en de folders dus.
Ik gebruik folders x,y,z die moeten dan dus vrij zijn.
Even in notepad+ zetten en juist saven.
Mocht je een keer je pc eerder aanzetten dan de Nas kan je gewoon de .bat file starten en alles wordt gekoppeld.
drivemap.bat
@ECHO OFF
REM Edit by Wizjos 9/3/2013
REM !---- Command Script that waits until the network connection to a (local) network resource has been
REM !---- established, and only then mounts specified network locations as mapped drives.
REM !---- Useful in case setting up the network connection might take long following startup.
REM !---- This might e.g. apply to WiFi connections
REM !---- Script verified for WinXP (English version)
REM !---- Define the NAS IP-address or network name (e.g. "192.168.1.5" or "Diskstation"), but use -NO- quotes (")
REM !---- IP-address should always work; network name only when client and NAS are in the same Workgroup/Domain
SET nas_ip=192.168.1.1
REM !---- Use this section if NAS-username and/or -password differs from Windows-username and/or -password
REM !---- Omit this section ("REM" all lines) if Windows and NAS user-name and -password are identical
REM nas_usr=login
REM !---- Use the next line to be prompted for the NAS-user password. Preferred solution, safe
REM SET /p nas_pwd=Please provide password for remote user %nas_usr% on \%nas_ip%: ?
REM !---- Use the next line to put the NAS-user password in this file. Non-preferred, unsafe
REM nas_pwd=ww
REM !---- Modify the following variables according to need; value always between 1 and 254 (incl)
SET /a seconds_between_pings=3
SET /a max_attempts=90
SET /a seconds_of_end_message=10
SET /a min_good_pings=3
REM !---- Use the next line if you want to delete the links to ALL mapped network drives
REM USE * /DELETE
REM !---- Use the next line(s) (and modify drive-letters) if you want to delete specific mapped network drives
SET NET USE Z: /DELETE /y
SET NET USE Y: /DELETE /y
SET NET USE X: /DELETE /y
SET /a attempts=1
SET /a good_pings=0
SET display=Waiting for connection to %nas_ip% .
REM !--- Mind the white-space ( ) behind the last period (.) above !
:try_again
CLS
ECHO %display%
REM !--- The following line serves as a "wait" statement
PING -n %seconds_between_pings% -w 1 %nas_ip% >NUL
REM !--- You might (?) need to change "Reply from" below for non-English Windows versions
PING -n 1 -w 200 %nas_ip% | FIND "Reply from %nas_ip%" >NUL
IF %ERRORLEVEL% EQU 0 (SET /a good_pings+=1)
IF %good_pings% EQU %min_good_pings% GOTO :conn_established
SET display=%display:. =.. %
SET /a attempts+=1
IF %attempts% LEQ %max_attempts% GOTO :try_again
ECHO.
ECHO Connection to %nas_ip% failed to establish within reasonable time
ECHO.
ECHO Unable to map network drive(s) to %nas_ip%
ECHO.
GOTO :almost_oef
:conn_established
ECHO.
ECHO Connection to %nas_ip% established
ECHO.
ECHO Now mapping network drive(s)
IF N%nas_usr%==N (SET userdata="") ELSE (SET userdata="/USER:%nas_usr% %nas_pwd% ")
rem also OK for XP: IF defined nas_usr (SET userdata="/USER:%nas_usr% %nas_pwd% ") ELSE (SET userdata="")
rem not OK for XP: IF EXIST %%nas_usr%% (SET userdata="/USER:%nas_usr% %nas_pwd% ") ELSE (SET userdata="")
REM !---- add line(s), change drive-letter (e.g. K:) and NAS folder-name (e.g. nas_folder1) according to need
NET USE Z: \\%nas_ip%\\"hier je sharenaam" %userdata:"=%/PERSISTENT:NO
NET USE Y: \\%nas_ip%\\"hier je sharenaam" /PERSISTENT:NO
NET USE X: \\%nas_ip%\\"hier je sharenaam" /PERSISTENT:NO
REM NET USE L: \\%nas_ip%nas_folder2 %userdata:"=%/PERSISTENT:NO
:almost_oef
PING -n %seconds_of_end_message% -w 1 %nas_ip% >NUL
Het run.vbs scriptje in je windows opstart folder:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:drivemap" & Chr(34), 0
Set WshShell = Nothing