aaa
@echo off
echo --------------------------------------------------
echo Checking if B: \\172.19.170.14\home Drive exist? Please wait...
echo IMPORTANT: DO NOT TOUCH THE COMPUTER DURING THIS PROCESS
echo --------------------------------------------------
Rem : WMB 2014
Rem : note start time
echo [%DATE% - %TIME%] >> c:\users\public\runcheck.txt
Rem : Check for home location
Set NASGateway=130.127.166.65
@For /f "tokens=3" %%* in (
'route.exe print ^|findstr "\<0.0.0.0\>"'
) Do @Set "DefaultGateway=%%*"
echo The Gateway is: [%DefaultGateway%] >> c:\users\public\runcheck.txt
IF %DefaultGateway% NEQ %NASGateway% (
echo.
echo We are not at home. Bailing out! >> c:\users\public\runcheck.txt
GOTO END
) ELSE (
echo everything is exactly perfect! >> c:\users\public\runcheck.txt
goto MAPTIME
)
:MAPTIME
Rem : Set log file location to the public user directory
SET LOG=c:\users\public
Rem : log the results of mapping the drive
echo **********[%Date% - %Time%****************>%LOG%\Mapdrive.log
IF EXIST B:\ (
echo.
echo The drive is already mapped.
echo ...Check if the mapp drive is accessible?....
echo.
dir B: >>%LOG%\Mapdrive.log
if ERRORLEVEL 1 GOTO MAPDRIVE
GOTO SKIPPED
) ELSE (
echo The drive has not yet been mapped.
goto MAPDRIVE
)
goto copy
:SKIPPED
echo.
Echo ******Mapped Drive B is working Fine********
Echo.
Goto copy
Rem : Change IP below for your NAS!
:MAPDRIVE
Net use B: /d
net use B: \\172.19.170.14\home
dir b: >> %LOG%\Mapdrive.log
if errorlevel 0 goto SKIPPED
if errorlevel 1 goto MAPDRIVE
Goto copy
echo --------------------------------------------------
echo Checking if B: \\172.19.170.14\home Drive exist? Please wait...
echo IMPORTANT: DO NOT TOUCH THE COMPUTER DURING THIS PROCESS
echo --------------------------------------------------
Rem : WMB 2014
Rem : note start time
echo [%DATE% - %TIME%] >> c:\users\public\runcheck.txt
Rem : Check for home location
Set NASGateway=130.127.166.65
@For /f "tokens=3" %%* in (
'route.exe print ^|findstr "\<0.0.0.0\>"'
) Do @Set "DefaultGateway=%%*"
echo The Gateway is: [%DefaultGateway%] >> c:\users\public\runcheck.txt
IF %DefaultGateway% NEQ %NASGateway% (
echo.
echo We are not at home. Bailing out! >> c:\users\public\runcheck.txt
GOTO END
) ELSE (
echo everything is exactly perfect! >> c:\users\public\runcheck.txt
goto MAPTIME
)
:MAPTIME
Rem : Set log file location to the public user directory
SET LOG=c:\users\public
Rem : log the results of mapping the drive
echo **********[%Date% - %Time%****************>%LOG%\Mapdrive.log
IF EXIST B:\ (
echo.
echo The drive is already mapped.
echo ...Check if the mapp drive is accessible?....
echo.
dir B: >>%LOG%\Mapdrive.log
if ERRORLEVEL 1 GOTO MAPDRIVE
GOTO SKIPPED
) ELSE (
echo The drive has not yet been mapped.
goto MAPDRIVE
)
goto copy
:SKIPPED
echo.
Echo ******Mapped Drive B is working Fine********
Echo.
Goto copy
Rem : Change IP below for your NAS!
:MAPDRIVE
Net use B: /d
net use B: \\172.19.170.14\home
dir b: >> %LOG%\Mapdrive.log
if errorlevel 0 goto SKIPPED
if errorlevel 1 goto MAPDRIVE
Goto copy
http://www.codeproject.com/Articles/7951/Dynamic-Dialog-Box
http://my.oschina.net/ypimgt/?disp=2&catalog=0&p=9