PC Review


Reply
Thread Tools Rate Thread

Batch file to reconnect home NAS

 
 
bwawawa@gmail.com
Guest
Posts: n/a
 
      16th Oct 2007
I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
in it for my home network to store files files like MP3's, pictures
and to back up all my computers. I don't have domain server at my
home. Everytime I reboot the NAS need me to remap the drives and
sometimes it doesn't even take my password that I'd have to
'disconnect' all mapped drive and remap. It's kinda annoying. I
started creating this batch file piece by piece based on someone else
batch file to connect to my private folder as p: drive, s: drive as
public drive and t: drive as the 160GB Seagate USB external drive.

@echo off
cls
if exist p: goto drivefound2 else
goto end
:drivefound2
net use p: /del
:end

pause

if exist s: goto drivefound3
goto end
:drivefound3
net use s: /del
:end

pause

if exist t: goto drivefound4
goto end
:drivefound4
net use t: /del
:end

pause

net use p: \\airnas\default mypassword /user:airnas\default rem
default as private folder
net use s: \\airnas\public
net use t: \\airnas\usb_disk\usb_c

:END
echo DONE!

Is there anything more it can look better than this?

 
Reply With Quote
 
 
 
 
Todd Vargo
Guest
Posts: n/a
 
      17th Oct 2007
(E-Mail Removed) wrote:
> I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
> in it for my home network to store files files like MP3's, pictures
> and to back up all my computers. I don't have domain server at my
> home. Everytime I reboot the NAS need me to remap the drives and
> sometimes it doesn't even take my password that I'd have to
> 'disconnect' all mapped drive and remap. It's kinda annoying. I
> started creating this batch file piece by piece based on someone else
> batch file to connect to my private folder as p: drive, s: drive as
> public drive and t: drive as the 160GB Seagate USB external drive.
>
> @echo off
> cls
> if exist p: goto drivefound2 else
> goto end
> :drivefound2
> net use p: /del
> :end
>
> pause
>
> if exist s: goto drivefound3
> goto end
> :drivefound3
> net use s: /del
> :end
>
> pause
>
> if exist t: goto drivefound4
> goto end
> :drivefound4
> net use t: /del
> :end
>
> pause
>
> net use p: \\airnas\default mypassword /user:airnas\default rem
> default as private folder
> net use s: \\airnas\public
> net use t: \\airnas\usb_disk\usb_c
>
> :END
> echo DONE!
>
> Is there anything more it can look better than this?


First of all, you can not have more than one label named "end". Well you
could, but only the first one will be seen by the GOTO statement. Second,
your 3 "IF EXIST" conditions only skip the GOTO statement that follows them.
If you reconstruct as "IF NOT EXIST" conditions, you could eliminate one
GOTO statement and one label each. The following code has a cleaner
appearance and IMO, is easier to follow program flow. Do you agree?

@echo off
cls
if not exist p: goto skip_p
net use p: /del
:skip_p

if not exist s: goto skip_s
net use s: /del
:skip_s

if not exist t: goto skip_t
net use t: /del
:skip_t

net use p: \\airnas\default mypassword /user:airnas\default
net use s: \\airnas\public
net use t: \\airnas\usb_disk\usb_c
echo DONE!

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
 
 
 
foxidrive
Guest
Posts: n/a
 
      17th Oct 2007
On Tue, 16 Oct 2007 20:46:36 -0000, (E-Mail Removed) wrote:

>I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
>in it for my home network to store files files like MP3's, pictures
>and to back up all my computers. I don't have domain server at my
>home. Everytime I reboot the NAS need me to remap the drives and
>sometimes it doesn't even take my password that I'd have to
>'disconnect' all mapped drive and remap. It's kinda annoying. I
>started creating this batch file piece by piece based on someone else
>batch file to connect to my private folder as p: drive, s: drive as
>public drive and t: drive as the 160GB Seagate USB external drive.
>



@echo off
cls
if exist p: net use p: /del
if exist s: net use s: /del
if exist t: net use t: /del
net use p: \\airnas\default mypassword /user:airnas\default
net use s: \\airnas\public
net use t: \\airnas\usb_disk\usb_c
echo DONE!


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a
 
      17th Oct 2007

"Todd Vargo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (E-Mail Removed) wrote:
>> I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
>> in it for my home network to store files files like MP3's, pictures
>> and to back up all my computers. I don't have domain server at my
>> home. Everytime I reboot the NAS need me to remap the drives and
>> sometimes it doesn't even take my password that I'd have to
>> 'disconnect' all mapped drive and remap. It's kinda annoying. I
>> started creating this batch file piece by piece based on someone else
>> batch file to connect to my private folder as p: drive, s: drive as
>> public drive and t: drive as the 160GB Seagate USB external drive.
>>
>> @echo off
>> cls
>> if exist p: goto drivefound2 else
>> goto end
>> :drivefound2
>> net use p: /del
>> :end
>>
>> pause
>>
>> if exist s: goto drivefound3
>> goto end
>> :drivefound3
>> net use s: /del
>> :end
>>
>> pause
>>
>> if exist t: goto drivefound4
>> goto end
>> :drivefound4
>> net use t: /del
>> :end
>>
>> pause
>>
>> net use p: \\airnas\default mypassword /user:airnas\default rem
>> default as private folder
>> net use s: \\airnas\public
>> net use t: \\airnas\usb_disk\usb_c
>>
>> :END
>> echo DONE!
>>
>> Is there anything more it can look better than this?

>
> First of all, you can not have more than one label named "end". Well you
> could, but only the first one will be seen by the GOTO statement. Second,
> your 3 "IF EXIST" conditions only skip the GOTO statement that follows
> them.
> If you reconstruct as "IF NOT EXIST" conditions, you could eliminate one
> GOTO statement and one label each. The following code has a cleaner
> appearance and IMO, is easier to follow program flow. Do you agree?
>
> @echo off
> cls
> if not exist p: goto skip_p
> net use p: /del
> :skip_p
>
> if not exist s: goto skip_s
> net use s: /del
> :skip_s
>
> if not exist t: goto skip_t
> net use t: /del
> :skip_t
>
> net use p: \\airnas\default mypassword /user:airnas\default
> net use s: \\airnas\public
> net use t: \\airnas\usb_disk\usb_c
> echo DONE!


Or how about this version:

@echo off
cls
if exist p: net use p: /del
if exist s: net use p: /del
if exist t: net use t: /del

net use p: \\airnas\default mypassword /user:airnas\default
net use s: \\airnas\public
net use t: \\airnas\usb_disk\usb_c
echo DONE!

If more than one statement needs to be executed in each block, this can be
achieved like this:

if exist p: echo/disconnecting drive P: & net use p: /del

or like this:

if exist p: (
echo/disconnecting drive P:
net use p: /del
)


/Al


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a
 
      17th Oct 2007

"foxidrive" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Tue, 16 Oct 2007 20:46:36 -0000, (E-Mail Removed) wrote:
>
>>I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
>>in it for my home network to store files files like MP3's, pictures
>>and to back up all my computers. I don't have domain server at my
>>home. Everytime I reboot the NAS need me to remap the drives and
>>sometimes it doesn't even take my password that I'd have to
>>'disconnect' all mapped drive and remap. It's kinda annoying. I
>>started creating this batch file piece by piece based on someone else
>>batch file to connect to my private folder as p: drive, s: drive as
>>public drive and t: drive as the 160GB Seagate USB external drive.
>>

>
>
> @echo off
> cls
> if exist p: net use p: /del
> if exist s: net use s: /del
> if exist t: net use t: /del
> net use p: \\airnas\default mypassword /user:airnas\default
> net use s: \\airnas\public
> net use t: \\airnas\usb_disk\usb_c
> echo DONE!


Sheesh, Al, read first *then* post!

/Al


 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      17th Oct 2007
On Tue, 16 Oct 2007 23:51:47 -0600, "Al Dunbar" <(E-Mail Removed)>
wrote:

>> echo DONE!

>
>Sheesh, Al, read first *then* post!



<laughs>

That'll be ten lashes, Al.

 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      17th Oct 2007
Al Dunbar wrote:
> Todd Vargo wrote:
> > (E-Mail Removed) wrote:
> >> I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
> >> in it for my home network to store files files like MP3's, pictures
> >> and to back up all my computers. I don't have domain server at my
> >> home. Everytime I reboot the NAS need me to remap the drives and
> >> sometimes it doesn't even take my password that I'd have to
> >> 'disconnect' all mapped drive and remap. It's kinda annoying. I
> >> started creating this batch file piece by piece based on someone else
> >> batch file to connect to my private folder as p: drive, s: drive as
> >> public drive and t: drive as the 160GB Seagate USB external drive.
> >>
> >> @echo off
> >> cls
> >> if exist p: goto drivefound2 else
> >> goto end
> >> :drivefound2
> >> net use p: /del
> >> :end
> >>
> >> pause
> >>
> >> if exist s: goto drivefound3
> >> goto end
> >> :drivefound3
> >> net use s: /del
> >> :end
> >>
> >> pause
> >>
> >> if exist t: goto drivefound4
> >> goto end
> >> :drivefound4
> >> net use t: /del
> >> :end
> >>
> >> pause
> >>
> >> net use p: \\airnas\default mypassword /user:airnas\default rem
> >> default as private folder
> >> net use s: \\airnas\public
> >> net use t: \\airnas\usb_disk\usb_c
> >>
> >> :END
> >> echo DONE!
> >>
> >> Is there anything more it can look better than this?

> >
> > First of all, you can not have more than one label named "end". Well you
> > could, but only the first one will be seen by the GOTO statement.

Second,
> > your 3 "IF EXIST" conditions only skip the GOTO statement that follows
> > them.
> > If you reconstruct as "IF NOT EXIST" conditions, you could eliminate one
> > GOTO statement and one label each. The following code has a cleaner
> > appearance and IMO, is easier to follow program flow. Do you agree?
> >
> > @echo off
> > cls
> > if not exist p: goto skip_p
> > net use p: /del
> > :skip_p
> >
> > if not exist s: goto skip_s
> > net use s: /del
> > :skip_s
> >
> > if not exist t: goto skip_t
> > net use t: /del
> > :skip_t
> >
> > net use p: \\airnas\default mypassword /user:airnas\default
> > net use s: \\airnas\public
> > net use t: \\airnas\usb_disk\usb_c
> > echo DONE!

>
> Or how about this version:
>
> @echo off
> cls
> if exist p: net use p: /del
> if exist s: net use p: /del
> if exist t: net use t: /del
>
> net use p: \\airnas\default mypassword /user:airnas\default
> net use s: \\airnas\public
> net use t: \\airnas\usb_disk\usb_c
> echo DONE!


Well done! I guess pointing out the erroneous use of multiple labels with
same name was of greater concern to me. <shrug>


>
> If more than one statement needs to be executed in each block, this can be
> achieved like this:
>
> if exist p: echo/disconnecting drive P: & net use p: /del


IMO, does not fall into the "look better" description".


>
> or like this:
>
> if exist p: (
> echo/disconnecting drive P:
> net use p: /del
> )


Yes, this way is better, however, I still use Windows 98 so still seem to
use universal code.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
bwawawa@gmail.com
Guest
Posts: n/a
 
      17th Oct 2007
On Oct 17, 3:31 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> Al Dunbar wrote:
> > Todd Vargo wrote:
> > > bwaw...@gmail.com wrote:
> > >> I bought a Airlink101 Office NAS ANAS350 with 500GB Seagate SATA drive
> > >> in it for my home network to store files files like MP3's, pictures
> > >> and to back up all my computers. I don't have domain server at my
> > >> home. Everytime I reboot the NAS need me to remap the drives and
> > >> sometimes it doesn't even take my password that I'd have to
> > >> 'disconnect' all mapped drive and remap. It's kinda annoying. I
> > >> started creating this batch file piece by piece based on someone else
> > >> batch file to connect to my private folder as p: drive, s: drive as
> > >> public drive and t: drive as the 160GB Seagate USB external drive.

>
> > >> @echo off
> > >> cls
> > >> if exist p: goto drivefound2 else
> > >> goto end
> > >> :drivefound2
> > >> net use p: /del
> > >> :end

>
> > >> pause

>
> > >> if exist s: goto drivefound3
> > >> goto end
> > >> :drivefound3
> > >> net use s: /del
> > >> :end

>
> > >> pause

>
> > >> if exist t: goto drivefound4
> > >> goto end
> > >> :drivefound4
> > >> net use t: /del
> > >> :end

>
> > >> pause

>
> > >> net use p: \\airnas\default mypassword /user:airnas\default rem
> > >> default as private folder
> > >> net use s: \\airnas\public
> > >> net use t: \\airnas\usb_disk\usb_c

>
> > >> :END
> > >> echo DONE!

>
> > >> Is there anything more it can look better than this?

>
> > > First of all, you can not have more than one label named "end". Well you
> > > could, but only the first one will be seen by the GOTO statement.

> Second,
> > > your 3 "IF EXIST" conditions only skip the GOTO statement that follows
> > > them.
> > > If you reconstruct as "IF NOT EXIST" conditions, you could eliminate one
> > > GOTO statement and one label each. The following code has a cleaner
> > > appearance and IMO, is easier to follow program flow. Do you agree?

>
> > > @echo off
> > > cls
> > > if not exist p: goto skip_p
> > > net use p: /del
> > > :skip_p

>
> > > if not exist s: goto skip_s
> > > net use s: /del
> > > :skip_s

>
> > > if not exist t: goto skip_t
> > > net use t: /del
> > > :skip_t

>
> > > net use p: \\airnas\default mypassword /user:airnas\default
> > > net use s: \\airnas\public
> > > net use t: \\airnas\usb_disk\usb_c
> > > echo DONE!

>
> > Or how about this version:

>
> > @echo off
> > cls
> > if exist p: net use p: /del
> > if exist s: net use p: /del
> > if exist t: net use t: /del

>
> > net use p: \\airnas\default mypassword /user:airnas\default
> > net use s: \\airnas\public
> > net use t: \\airnas\usb_disk\usb_c
> > echo DONE!

>
> Well done! I guess pointing out the erroneous use of multiple labels with
> same name was of greater concern to me. <shrug>
>
>
>
> > If more than one statement needs to be executed in each block, this can be
> > achieved like this:

>
> > if exist p: echo/disconnecting drive P: & net use p: /del

>
> IMO, does not fall into the "look better" description".
>
>
>
> > or like this:

>
> > if exist p: (
> > echo/disconnecting drive P:
> > net use p: /del
> > )

>
> Yes, this way is better, however, I still use Windows 98 so still seem to
> use universal code.
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)


Thanks folks. I got scared when I saw Rob Vanderwoude batch file
sample.

 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      18th Oct 2007
(E-Mail Removed) wrote:
> On Oct 17, 3:31 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> > Al Dunbar wrote:

....
> > > or like this:

> >
> > > if exist p: (
> > > echo/disconnecting drive P:
> > > net use p: /del
> > > )

> >
> > Yes, this way is better, however, I still use Windows 98 so still seem

to
> > use universal code.

>
> Thanks folks. I got scared when I saw Rob Vanderwoude batch file
> sample.


Which sample was that?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server vs NAS vs File Share for a small home network. B3thj3nkns@Hotmail.Com DIY PC 6 27th Oct 2012 07:00 AM
Iomega NAS or any NAS question muahman@gmail.com Storage Devices 0 6th Jun 2006 03:18 AM
USB 2.0 hubs drop-reconnect-drop-reconnect....? CraigNJ Asus Motherboards 17 1st Aug 2005 06:06 AM
Home NAS question: NAS Suggestions for Dummies needed Ken K Storage Devices 38 26th Mar 2005 12:43 AM
Batch File to Reconnect to Mapped Drive EER Microsoft Windows 2000 CMD Promt 3 25th May 2004 07:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:12 AM.