![]() ![]() Rem Filter the line with the ip-address and MAC from arp -a and take action if foundĪrp -a | find /I "%IP%" | find /I "%routermac%" Rem Ping it to make sure it appears in arp -a output Rem so the computer probably isn't connected to any networkĮcho No gateway found after 20 seconds, giving up Rem 10 attempts over 20 seconds and we still cannot find a default gateway, Rem Carefull! There is 1 extra space before the ip-address.įor /f "delims=: tokens=2 usebackq" %%a in ( `ipconfig ^| find /I "default gateway"` ) do ( Rem Pull the default gateways from ipconfig and extract the one with a value. Rem using "arp -a" from the command line and looking for ![]() Rem whether or not the computer is at home. Rem routermac - The MAC address of the home router, used to determine ![]() Rem and, if so, attempts to re-attach disconnected network drives. Rem Batch file which checks if you are running on your home network To use the enhanced script, save the code below locally as automount.bat, make sure you set routermac correctly and then create a scheduled task to run it with the trigger to be "On workstation unlock". Whilst the above works just fine, I personally put this into a slightly more complicated script which first checks to see if you are actually on your home network before trying to map your drives. Rem Next line probably not essential, but doesn't seem to hurt The advantage of this approach is that you don't have to maintain a list of the drives you have mapped and it'll happily handle any drives you add (or remove) at a later date without modification: offįor /f "tokens=2,3" %%a in ( 'net use ^| findstr /I "unavailable disconnected"' ) do ( The following batch file looks at what drives you have mapped that are marked as "unavailable" or "disconnected" and then tries to map them again. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |