Mapped drive needs to be "activated"

Networking, connecting to the internet, wi-fi and home entertainment
User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Mapped drive needs to be "activated"

Post by jonwallace »

Hi guys,

I have a NSLU2 (uNslung) attached to a harddrive for external storage. This is mapped to a drive letter on my Windows XP SP3 main PC and the OH laptop (OS as main PC). This all works great as external storage if we use Windows explorer to Open the drive. If we don't double click the drive, backup programs (Karen's Replicator on the laptop and Ceren Backup on main PC) don't see the drive.

Does anyone know of a way to "activate" a mapped drive at bootup, so that we don't have to remember (old brains, losing brain cells daily - desperately need a memory upgrade :bummer: ) to open the drive before scheduled backup time?
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Mapped drive needs to be "activated"

Post by StuartR »

Would a little .BAT file in your Startup folder, that just gets a directory listing of the top folder on the drive work?
StuartR


User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: Mapped drive needs to be "activated"

Post by jonwallace »

StuartR wrote:Would a little .BAT file in your Startup folder, that just gets a directory listing of the top folder on the drive work?
That's a good idea, I could always direct output to null to avoid a popup window hanging about (this is the main reason I don't just stick a shortcut to the drive in startup)

Something like

Code: Select all

@echo off
dir y: > nul
exit

should do don't you think? I'll try that tomorrow.
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Mapped drive needs to be "activated"

Post by John Gray »

You could make that a one-liner:

Code: Select all

@dir y: > nul
since EXIT is redundant in that situation! That's unless you also want to be sure it's there...

DIR is a more reliable way of checking that a drive is available rather than IF EXIST <filename>. I have set up backups from server to TrueCrypt-ed PC hard disk partitions, and check that the TrueCrypt MOUNT command has worked by doing a DIR of the drive letter and checking for a zero errorlevel.
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: Mapped drive needs to be "activated"

Post by jonwallace »

Ok, John and Stuart (and unseen audience)

I've tried the batch file suggested, (neat one-liner by the way, it's been too long since I had to DOS it) but until the Drive has been opened by explorer all I get is "system cannot find path specified".

I can do a

Code: Select all

Explorer /root,y:
which does open the Y: drive window (then the batch file is redundant) but then I have to manually close the window. I don't mind this but other people in the house (and they know who they are...) will object.

Any suggestions for opening then closing the window without anyone (her) seeing it?
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Mapped drive needs to be "activated"

Post by StuartR »

jonwallace wrote:...until the Drive has been opened by explorer all I get is "system cannot find path specified"...
Strange.

You could try a command like

Code: Select all

NET USE \\computer\ipc$
to make sure you have a session connected to the target computer, or even

Code: Select all

NET USE G: \\computer\share
where G is the correct drive letter for your share

Try each of these commands in the BAT file before the DIR and see if they do the trick.
StuartR


User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: Mapped drive needs to be "activated"

Post by jonwallace »

Thanks for the suggestion, I'll give those a go tomorrow.
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube

User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: Mapped drive needs to be "activated"

Post by jonwallace »

Thanks guys :cheers: ,

the NET USE G: \\computer\share bit looks like the command to do the trick, especially when I remember to put quotes round the path with a space in it.

I'll incorporate it into a BAT file with a @ at the start and a >nul at the end to make it silent (that will make it silent, won't it?)
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Mapped drive needs to be "activated"

Post by StuartR »

jonwallace wrote:...a BAT file with a @ at the start and a >nul at the end to make it silent (that will make it silent, won't it?)
To make a BAT file silent you should have
@echo Off
as the first line

Ah, I have just understood, you want to direct any output to the null device, so the >NUL is not at the end of the BAT file, it is at the end of the command that runs the bat file.
StuartR


User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Mapped drive needs to be "activated"

Post by John Gray »

jonwallace wrote:the NET USE G: \\computer\share bit looks like the command to do the trick, especially when I remember to put quotes round the path with a space in it.
I'll incorporate it into a BAT file with a @ at the start and a >nul at the end to make it silent (that will make it silent, won't it?)
The @ at front of the command will make that command silent, but not the whole BATch file.
To be really, really, sure that the command will produce no output, you should put
1>nul 2>&1
at the end, but that means you would never see any error message (stream 2).
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: Mapped drive needs to be "activated"

Post by jonwallace »

Update:

Code: Select all

@NET USE G: \\computer\share > nul
Does what I want for the moment. I haven't tried to trap for failure of the command, because frankly, the "customer" (the wife) doesn't want to be bothered with failed DOS boxes hanging around :groan:

Thanks again for the help guys, :cheers: saved me going in the loft for my DOS books :wine:
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube

User avatar
jonwallace
5StarLounger
Posts: 1120
Joined: 26 Jan 2010, 11:32
Location: "What a mighty long bridge to such a mighty little old town"

Re: Mapped drive needs to be "activated"

Post by jonwallace »

jonwallace wrote:Update:

Code: Select all

@NET USE G: \\computer\share > nul
Does what I want for the moment.
Final update: I was wrong about the code above. It worked on my wired PC, but on her wireless laptop, it failed because it tried to connect before the network connection was ready. :sad:

I hopped over here and following advice I ended up with this BAT file

Code: Select all

@Echo Off
:CheckNet
ping -n 1 -w 1000 www.google.co.uk |find /I "Reply"
If %Errorlevel%==1 goto CheckNet
NET USE G: \\computer\share > nul 
which wanders round a loop pinging google until it finds it, (meaning the network's connected) then maps the drive. Putting a shortcut in startup with the properties set to run minimized puts the CMD window on the taskbar, instead of obscuring her lovely wallpaper image :grin: and everybody's happy (til the next time...)
John

“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube