Thanks barry, but your last line:
NET USE Y: \\DC\Data
would generate an error wouldn't it if y: already existed.
what you need is an else statement after your second line.
...but not sure how to do else statements in batch code.
But yes I could use your solution I guess. Let's see if anyone's got a more 'best practise' way because this seems like a workaround, albeit a clever one.
Main Topics
Browse All Topics





by: barryhiggins3Posted on 2009-06-08 at 07:41:18ID: 24572574
O.K.
What you need is something you can referance within the \\DC\Data, a file that all users have access to, for illustrative purposes lets say test.txt in the \\DC\Data share.
So a simple .bat file with the below should do the trick. (If Y: Already exists but is mapped to another location it will use X), you can of course change this or nest multiple checks to scan through several letters until you find one that's not being used.
IF EXIST "Y:\test.txt" exit
IF EXIST "Y:\" (
Net use X: \\DC\Data
)
NET USE Y: \\DC\Data