I have two files *.CMD, each of them makes the G Drive mount to different locations using

NET USE G: "\\10.10......

I would like a single file to switch the mount path. How can I know to where my G Drive is connected at the moment?

link|improve this question
feedback

1 Answer

@echo off & setlocal

(net use G: | findstr /b "Remote" | find "\\pathone" > nul) && goto :usetwo
goto :useone

:useone
    net use G: /y /d && net use G: \\pathone
    goto :eof

:usetwo
    net use G: /y /d && net use G: \\pathtwo
    goto :eof

a && b means that command b will only be run if a succeeds. (a || b will only run b if a does not succeed.)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.