Mombu the Microsoft Forum

Mombu the Microsoft Forum > Microsoft > Windows 2000 Server (TECHNET) > Batch file to reconnect home NAS
REGISTER NOW! Mark Forums Read




Reply
 
Thread Tools Display Modes
1 18th October 19:59
bwawawa
External User
 
Posts: 1
Default Batch file to reconnect home NAS



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
SPONSORED LINKS BY GOOGLE

 


2 18th October 19:59
todd vargo
External User
 
Posts: 1
Default Batch file to reconnect home NAS



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
3 18th October 19:59
foxidrive
External User
 
Posts: 1
Default Batch file to reconnect home NAS


@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
4 18th October 19:59
al dunbar
External User
 
Posts: 1
Default Batch file to reconnect home NAS


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
5 18th October 19:59
al dunbar
External User
 
Posts: 1
Default Batch file to reconnect home NAS


Sheesh, Al, read first *then* post!

/Al
  Reply With Quote
6 18th October 19:59
foxidrive
External User
 
Posts: 1
Default Batch file to reconnect home NAS


<laughs>

That'll be ten lashes, Al.
  Reply With Quote
7 18th October 20:00
todd vargo
External User
 
Posts: 1
Default Batch file to reconnect home NAS


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


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


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
8 18th October 20:00
bwawawa
External User
 
Posts: 1
Default Batch file to reconnect home NAS


Thanks folks. I got scared when I saw Rob Vanderwoude batch file
sample.
  Reply With Quote
9 18th October 20:00
todd vargo
External User
 
Posts: 1
Default Batch file to reconnect home NAS


Which sample was that?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


Reply


Thread Tools
Display Modes







Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
Also visit Ogoun the Usenet Archive
666