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)
|