Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .