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.
LVL 5
bfuchsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dany BalianCTOCommented:
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
0
bfuchsAuthor Commented:
@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
0
Dany BalianCTOCommented:
You should let it run on start! The batch should run once!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bfuchsAuthor Commented:
I did execute the batch the first thing after restart.
Do you mean it must be run as startup?
0
Dany BalianCTOCommented:
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
0
bfuchsAuthor Commented:
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
0
Dany BalianCTOCommented:
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!
0
bfuchsAuthor Commented:
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
0
bfuchsAuthor Commented:
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.
0
Dany BalianCTOCommented:
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
0
Dany BalianCTOCommented:
Also try net use /delete * before any other command (warning: this will delete all existing connections to any network resources)
0
bfuchsAuthor Commented:
Hi,

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

Ben
0
bfuchsAuthor Commented:
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
0
Dany BalianCTOCommented:
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?
0
bfuchsAuthor Commented:
see attached
Untitled.png
0
bfuchsAuthor Commented:
btw, currently I restart the pc every time I want undo the route cmd, is there a command to do that instead?
0
Dany BalianCTOCommented:
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 *
0
Dany BalianCTOCommented:
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?
0
bfuchsAuthor Commented:
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

0
Dany BalianCTOCommented:
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!
0
bfuchsAuthor Commented:
@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
0
Dany BalianCTOCommented:
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
0
bfuchsAuthor Commented:
@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
0
Dany BalianCTOCommented:
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
0
bfuchsAuthor Commented:
Hi Dany,

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

Thanks,
Ben
0
bfuchsAuthor Commented:
@Dany,

OK this is the story..

I tried adding pause after each command on batch and it gave me successfull messages, however the folder still didnt got recognized before manually clicking..

Meanwhile I had a IT consultant look at the script and he basically just suggested adding the following -p to the route script and that takes care of all, meaning there is no need to run daily scripts and no need to double click at folder, its all setup..
route add -p 999.999.1.999 mask 255.255.255.255 999.2.1.1

Open in new window


Thanks,
Ben
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dany BalianCTOCommented:
Well the -p makes the route persistent.. I never suggested it coz i thought the route was already made.. Anyways i'm glad it worked
0
bfuchsAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Network Operations

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.