Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Map local folders to drive letters

    I'm trying to find a consistent way to refer to My Documents folder which resides in 3 different locations on my 3 computers. In this thread I asked for help in finding the name of the %documents% variable, only to find that it didn't exist, but one suggestion was to map a drive to the folder in question and then use that path on all computers. So, for instance, my sysadmin maps my space on the network drive to u:, so I planned to map my documents folder on the laptop and home computer to u:. Only problem - can't seem to do it! Whenever I try and map "My Documents" to u:, I either receive the error "not logged on", or the error that I can't do this with a drive on this computer. I've tried browsing the network to get back to this folder that way, and the network is unavailable. This computer is in a workgroup rather than a domain, and I'm using win2k pro. In order for this to work well for me, however, I need to be able to do this on computers belonging to domains as well (the whole idea being that the database is portable between home, work and laptop).

    Am I doing something wrong?

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Map local folders to drive letters

    You're not doing something wrong.....you can't do a true remapping with a local directory. You do, however, have a few options:

    <UL><LI>SUBST. You can use the SUBST command to refer to a local drive, although it's quirky at times - but it works. The syntax is:<pre>SUBST [drive1: [drive2:]path]</pre>

    where drive1 is the virtual drive you want to use, and drive2 is the path that you wish the SUBST'd drive to refer to.

    <LI>You can also use reparse points in the NTFS file syste, which are far more complex and quite possibly overkill. PCGuide has a good reference here: http://www.pcguide.com/ref/hdd/file/...Reparse-c.html. I've used WinLink to manage them before with success (why Microsoft didn't make this a bit easier to handle I don't know).[/list]HTH,
    -Mark

  3. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Map local folders to drive letters

    Thanks Mark. Option 2 doesn't apply as all local drives are FAT32. I'd just like to check before I use it, when you say that SUBST is quirky, what do you mean?

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Map local folders to drive letters

    Rather than try to explain it myself and miss something that might be of value to you, I checked to see if I could find an old reference....and I did. Brian Livingston explains the quirks of the SUBST command in concise detail, better than I would have. This also reminded me of the possibility of using the NET USE command to do essentially the same thing - take a look at his article and see if it helps you.

    Cheers,
    -Mark

  5. #5
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Map local folders to drive letters

    Thanks Mark

  6. #6
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Map local folders to drive letters

    One last query, and maybe this is a testing one. I use my laptop both connected to the network and not, but with the same user profile (ie always try to log on to the domain, and failing if not connected). Is there a way I can test in the batch file whether or not I'm connected, because I don't want to map the folder if I'm connected?

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Map local folders to drive letters

    Indeed you can. Try something like this:

    <pre>IF EXIST ServerNameSomeShareName*. (
    ECHO The share exists
    ) ELSE (
    ECHO Share not there!
    )</pre>

    Where ServerName is a the server and SomeShareName is the share you are looking for. Save it as checkshare.bat or somthing like that, and put it in your startup group.

    A side note - there will be a small delay in the BAT file if the share is not present, while the script tries to resolve the server's name. You can also use an IP address as well.

    HTH,
    -Mark

  8. #8
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Map local folders to drive letters

    Dear Mark,

    Thanks a lot. Sorry to bug you but I've a few questions about your example. After reading your post I looked at many online batch language resources, but couldn't find out the role of parentheses. How are they important? Also, what exactly does EXIST do. I can't find any help for it, and want to check how I might use it in future. In your example it seems to be looking for files (is the full stop after the * important?), but I guess I can try and see if it will work with just ServerName. If it can only be used with files, do I need to have any permissions to access a file on the specified resource in order for EXIST to "see" it? Can one use logical operators in the conditional expression? I also notice there's no THEN - so the syntax of conditional clauses in batch files is different.

    If there is a better source that would have answered these questions if I'd found it, please direct me there and I'll be happy to try and find out myself.

    Cheers

    Mark

  9. #9
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Map local folders to drive letters

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> You're not bugging anyone. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    The parenthesis are important in this instance. They will only work with the Windows NT command interpreter - if you were to try this on Windows 9x it would result in an error. Their purpose is to group certain commands/functions together so that they execute correctly. The IF EXIST tells Windows to execute a certain action IF the share/file EXISTS. It can also be modified to read IF NOT EXIST. In other words, it's telling the command interpreter to take a certain action ONLY if the specified target exists.

    So, to put this in perspective, the following statement:
    <pre>IF EXIST ServerNameSomeShareName*.

    ( ECHO The share exists)
    ELSE
    ( ECHO Share not there!)</pre>

    is saying "If SomeShareName is present on SomeServer, display the message "The share exists", otherwise display the message "Share not there".

    If the parenthesis were not there, your output would always be one of two things: nothing at all if the condition were true, or "The share exists ELSE ECHO Share not there!" as one big text string. The parenthesis separate the actions to take depending on whether or not the condition (the share exists) is true or not. If you can recall Algebra (ugh) it's the same idea - anything within those enclosures is treated as a separate, whole entity. The THEN that you refer to is implied - IF EXIST THEN take this action, ELSE do this in its stead.

    This logic can be used with many different things, not just files. This isn't the place to get into advanced shell scripting in Windows NT, but if it's something you are interested in, there are several references at most bookstores. You may also want to check out Windows Scripting Solutions as a reference - the BAT language in NT/2000/XP has a lot of extensions that weren't available in DOS.

    HTH,
    -Mark

  10. #10
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Map local folders to drive letters

    You can get simple syntax help for the IF command by typing <font color=blue>IF /?</font color=blue> at a DOS prompt.

    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •