How to wake a network drive from batch script?

5

1

I have a batch script which runs a robocopy. It is failing because the drive is not awake. enter image description here

In windows explorer, doubling clicking on that icon "wakes" up the link and the cross disappears and the robocopy runs without issue.

How can I wake it up in a batch file?

Additional Info: If my PC sleeps or reboots. The batch script does not run until i wake the drive via the icon. The two machines are not on a domain and they use the same username and password (administrator).

Additional Info 2: Note the unavailable drive.

Status       Local     Remote                    Network

---------------------------------------------------------------------------
OK           P:        \\fileserver2008\P        Microsoft Windows Network
Unavailable  T:        \\fileserver2008\T        Microsoft Windows Network

Valamas

Posted 2011-11-17T06:03:01.947

Reputation: 1 275

+1 because I'm interested in the solution for this for re-connecting drive letters after OpenVPN connections become fully functional. – Randolf Richardson – 2011-11-17T06:13:46.017

1I have added additional info – Valamas – 2011-11-17T10:12:26.360

Answers

7

I am not familiar with this problem but you may want to try out two things:

  1. Try running a Dir command against the drive and see if it wakes up: Dir T:\

  2. You can always disconnect and then connect the drive again from the command line, IE: from your batch program.

Yonatan Orlev

Posted 2011-11-17T06:03:01.947

Reputation: 71

+1: Reconnecting has always worked for me. – surfasb – 2011-11-17T18:27:40.860

The dir command results in The system cannot find the path specified.. I know that reconnecting the drive would work. I wish to avoid it as I would like to find something else. – Valamas – 2011-11-17T20:06:18.220

Solution 1 doesn't work for me either. Solution 2 is a last resort, but it's not as slick as the automatic re-connect. +1 for a great effort though. – Randolf Richardson – 2011-11-18T07:47:26.067

1

How about pinging it's IP address, does that wake it up? Failing that see if there's some kind of WOL command to cause the disk to initialise...

HaydnWVN

Posted 2011-11-17T06:03:01.947

Reputation: 3 192

1This doesn't wake up Windows network drive mappings, unfortunately. This is because ICMP is an entirely different protocol from SMB. +1 for a good attempt though. – Randolf Richardson – 2011-11-18T07:48:05.283

1+1 for the +1! Tend to always disable drive sleeping as all the network issues it used to cause... Old habits die hard :) – HaydnWVN – 2011-11-18T09:04:03.683