Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

Automating recognition of network drive

Hi Experts,
Due to a certain problem on our network, our IT guy instructed us to use the following in a batch file every time we restart the pc's,
@echo off
cls
cd \
route add XXX.XXX.1.XXX mask 255.255.255.255 XXX.2.1.1
pause
exit

Open in new window

this should make the folder on the server where our Access DB resides should be recognized
However the folder does not get to accessible until we open the windows browser and double click on that mapped network drive (N:).
Now I wonder if there is a way to avoid that extra last step?

It could be either by adding something to the batch file, or perhaps adding some code in our Access FE application that would accomplish that.

FYI- Only Win7 users are required to run that batch & need to have this fixed, while Win XP users are not required, and the network drive is immediately recognized upon restart.
Avatar of Dany Balian
Dany Balian
Flag of Lebanon image

Ok it seems the problem is a networking problem.. the subnet of the network drive could not be accessed at startup.. the solution is to map the network drive after the routing has been completed.
So, add this line before the pause:
net use N: \\xxx.xxx.1.xxx\myfolder /persistent:yes

Open in new window


if you can't map it yourself because you don't have the password to that resource then i suggest the following hack:

add this after the pause:
dir N:\bbbbbb

Open in new window


this will try to display the listing of the N drive and search for a file called bbbbbb.. the result will be a File not found but it will be as if you double clicked on the network drive :)

hope this helps
Avatar of bfuchs

ASKER

@Dany,

The first thing I get when adding your line is msg attached as untitleld.pgn
then I changed to the name already mapped (wgcts\data) and got second message attached as untitleld1.pgn

Thanks,
Ben
Untitled.png
Untitled1.png
You should let it run on start! The batch should run once!
Avatar of bfuchs

ASKER

I did execute the batch the first thing after restart.
Do you mean it must be run as startup?
Not necessarily as long as it runs only once! Because you can only add the same route once! Then after the route is added.. The dir should do the trick! Also the net use command can only be run once for the same drive name.. So, u should disconnect the map drive first! Or instead of n: try the command with x: and see if it works.. Also replace the dir n: with dir x: and tell me if it works
Avatar of bfuchs

ASKER

ok, I restarted pc, ran the following
@echo off
cls
cd \
route add 999.999.1.999 mask 255.255.255.255 999.2.1.1
net use X: \\999.999.1.999\data /persistent:yes
pause
exit

Open in new window

and got the attached
Untitled.png
Ok just run the route add alone in the command line..
Then go to start > Run and type \\999.999.1.999\data and see if the folder opens! Also try to ping 999.999.1.999 once the route is done to verify that u don't have connectivity issues!
Avatar of bfuchs

ASKER

Hi Dany,

I am little confused as to whats happening here...

before I started playing with this, all my network drives were accessible
however now none of them are..

Also I disconnected the N drive and wanted to re-mapped and I cant.

they are somehow connected as they show me the amount of disc space, but when I click on them, I get the error attached.

Perhaps I will have to call our IT guy first in order for us to proceed...

Thanks,
Ben
Untitled.png
Avatar of bfuchs

ASKER

FYI,
Ok just run the route add alone in the command line..
got message OK!
Also try to ping 999.999.1.999 once the route is done
getting back reply.
Then go to start > Run and type \\999.999.1.999\data and see if the folder opens!
nope.
So u have a problem with the network share! Maybe u need a password.. Try this for instance:
net use z: \\servername\folder /persistent:yes /user:username password
Also try net use /delete * before any other command (warning: this will delete all existing connections to any network resources)
Avatar of bfuchs

ASKER

Hi,

I am out of the office, our IT guy will check this tom & we will continue next week.
Have a nice weekend,

Ben
Avatar of bfuchs

ASKER

Hi Dany,

I had installed a couple of software into that pc last week and It looks like they are causing this network problem...

However I tried both of your original suggestions in another win7 pc, and none of them seems to be doing the trick, in other words without user manually clicking on N drive, the app gives you an error that N drive is not connected..Any other suggestions?


Thanks,
Ben
Unmap the network drive, then let it map using my command from the batch file.. Then try also the following please.. After the mapping type:
N:
Will that work?
Avatar of bfuchs

ASKER

see attached
Untitled.png
Avatar of bfuchs

ASKER

btw, currently I restart the pc every time I want undo the route cmd, is there a command to do that instead?
Well I wasn't talking about the route cmd.. I was talking About the mapping thing!
To delete the route u just type: route delete xxx.xxx.1.xxx
To cancel the mapping u just type:
Net use /delete *
Can u show me the list of commands typed in the batch file As they are, so i can analyze each error in ur screenshot?
Avatar of bfuchs

ASKER

Hi,
this is the batch
@echo off
cls
cd \
route add 999.999.1.999 mask 255.255.255.255 999.2.1.1
net use N: \\999.999.1.999\data /persistent:yes
N:
dir n:\bbb
pause
exit

Open in new window

The network path was not found.. Means the mapping did not succeed.. As long as the share is not accessible, nothing will work after that!
Avatar of bfuchs

ASKER

@Dany,

As originally stated, the batch w/o the additional line
net use N: \\999.999.1.999\data /persistent:yes

Open in new window

works, the issue is just having to manually double click on the N drive in order to get that fully recorgnized by all programs.

As far I know, we already tested all the following:

adding that line
adding dir n:\bbb
just adding n:
unmapping and have the batch map the drive
net use z: \\servername\folder /persistent:yes /user:username password
replace the dir n: with dir x:
...
So let me know what else should we try to get that done..

Thanks,
Ben
hello ben,

please try the following commands one after another in a command prompt window:

ping xxx.xxx.1.xxx

if ping gives you 4 successful pings, continue below!

net use k: \\xxx.xxx.1.xxx\your\network\share

the last message you should get is the following:
The command completed successfully.

if this succeeds then your network is ready.. we can go further
if you get the following message:
The network path was not found.
then, please verify the network path you just typed, it could be that you cannot access that specific path.
try to open the path using windows explorer, by typing: \\xxx.xxx.1.xxx\your\network\share into windows explorer and see what happens!
 
i just tried my script on my network with a network share outside of my subnet from both a windows xp pc and a windows 7 pc and both worked:
my ip address is: 10.254.177.11

this is the script i used:
ping 10.255.185.16
net use g: \\10.255.185.16\sharedfolder /user:mydomain\myuser mypassword /persistent:yes
dir g:
pause

Open in new window


and this is the result that i got:

C:\Documents and Settings\dandoon\Desktop>ping 10.255.185.16

Pinging 10.255.185.16 with 32 bytes of data:

Reply from 10.255.185.16: bytes=32 time=36ms TTL=126
Reply from 10.255.185.16: bytes=32 time=35ms TTL=126
Reply from 10.255.185.16: bytes=32 time=48ms TTL=126
Reply from 10.255.185.16: bytes=32 time=32ms TTL=126

Ping statistics for 10.255.185.16:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 32ms, Maximum = 48ms, Average = 37ms

C:\Documents and Settings\dandoon\Desktop>net use g: \\10.255.185.16\sharedfolder /user:mydomain\myuser mypassword /persistent:yes
The command completed successfully.

C:\Documents and Settings\dandoon\Desktop>dir g:
 Volume in drive G is Local Disk
 Volume Serial Number is 907C-EB3C

 Directory of G:\

31/10/2014  12:06 PM    <DIR>          .
31/10/2014  12:06 PM    <DIR>          ..
23/05/2014  11:42 AM         1,122,816 7z920 32 bit.msi
18/11/2010  10:03 PM         1,376,768 7z920-x64.msi
...
...
...
              26 File(s)     83,967,554 bytes
               4 Dir(s)  27,831,103,488 bytes free

C:\Documents and Settings\dandoon\Desktop>pause
Press any key to continue . . .

One last remark.. if you use the net use command the path  you use must not end with a backslash

net use x: \\xxx.xxx.1.xxx\my\share is correct
net use x: \\xxx.xxx.1.xxx\my\share\ is wrong
Avatar of bfuchs

ASKER

@Dany,
I think I know what is the problem here...

When I run the commands as a batch I get the attached, however when I try execute each command separately from DOS prompt they do execute successfully...

Therefore I guess we need to put in some logic to wait a few seconds after the route command..

Let me know if this makes sense.

Thanks,
Ben
Untitled.png
just for testing purposes, add the commands after the pause!
then on startup the system will give you a press any key to continue..
wait for a few seconds and then press any key.. and see if that's the issue so i can tell you how to add a delay in the batch
Avatar of bfuchs

ASKER

Hi Dany,

Out of the office, Will try next week when I am back.

Thanks,
Ben
ASKER CERTIFIED SOLUTION
Avatar of bfuchs
bfuchs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Thank you.