Wednesday, September 21, 2016

Map Drive Startup script: Check if connected to local WIFI

Check if WIFI Connected from BAT file / CMD. Is WIFI Connected from DOS Command?

So on my home/work network, each computer on my network has a startup script to map drives to my private cloud. The pain, however is when those computers/laptops are taken outside of my network and rebooted/started, the delay in boot time is increased due to the timeout of the startup script. So to improve boot time, we use this script:

So the simple solution algorithm is as follows:
If ping to a known home computer is OK then
    we are connected and map drives
else
    not connected do nothing.

In DOS cmd here is how we can achieve this:

1. Create a bat file: NetUses.User.bat
2. Paste this in and adjust the computer, domain, user names ect,

@echo off
echo MYCloud Login Script Start

ping -n 2 mycomputer > nul
if "%errorlevel%" == "0"
    goto connected
    echo Not Connected
    goto end

:connected
   echo Connected
   echo Mapping Drives
   echo off
   net use * /delete /yes
   NET USE M: \\mycomputer\share  /USER:mydomain\userID pwd
   NET USE Y: \\mycomputer\share  /USER:mydomain\userID pwd
:end

 
echo DoyleCloud Login Script DONE

No comments:

Post a Comment