Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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