Renaming Network Drive

Discussion in 'AutoCAD' started by petersciganek, Mar 2, 2005.

  1. Hello All,

    We have a separate drive set aside for "archived" projects - i.e. - projects that no longer need to be on the current project server but that do need to be immediately accessible for reference and occasionally to (re)plot. This leads to problems – particularly drawings with xrefs that have an absolute path and for users who have set their profiles to link CTB/PC3s by project. We are currently working in a manner that will resolve most of these issues in the future – but for now, we have to deal with thousands of archived drawings that will not display and/or plot correctly.

    One way to deal with this would be to run a lisp when necessary to search for + repath xrefs (and images) as required when a file is opened (though this won’t solve the CTB/PC3 issue).

    Before I do this, though, I thought that I would look into the option of temporarily resetting the archive drive letter to the project drive letter when a user wishes to open an archived file. Assuming that our project drive is “O†and the archive drive is “L†– is it somehow possible to “swap†the drive letters? I have looked into the DOS subst function – but this, as far as I can tell, will only allow a new letter/name for a virtual drive. The FileSystemObject Drive object’s DriveLetter property is read only.

    Do I need to disconnect and reconnect both network drives? If so – what would be the best means to do this? Also – any comments on potential pitfalls to this method would be appreciated.

    Thanks in advance,

    Peter
     
    petersciganek, Mar 2, 2005
    #1
  2. petersciganek

    Jürg Menzi Guest

    Hi Peter

    Try this:
    Code:
    (defun MeRemapNetworkDrive (Old New / DrvCol ItmCnt OldUnc RetVal WsnObj)
    (setq WsnObj (vlax-create-object "WScript.Network")
    DrvCol (vlax-invoke WsnObj 'EnumNetworkDrives)
    ItmCnt 0
    )
    (repeat (vlax-invoke DrvCol 'Count)
    (if (eq (strcase Old) (strcase (vla-Item DrvCol ItmCnt)))
    (setq OldUnc (vla-Item DrvCol (1+ ItmCnt)))
    )
    (setq ItmCnt (1+ ItmCnt))
    )
    (cond
    ((vl-catch-all-apply 'vlax-invoke (list WsnObj 'RemoveNetworkDrive Old)))
    ((vl-catch-all-apply 'vlax-invoke (list WsnObj 'MapNetworkDrive New OldUnc)))
    ((setq RetVal T))
    )
    (vlax-release-object WsnObj)
    RetVal
    )
    
    Use:
    (MeRemapNetworkDrive "L:" "O:")

    Cheers
     
    Jürg Menzi, Mar 2, 2005
    #2
  3. petersciganek

    Jürg Menzi Guest

    Oops... forgot something:

    Add :vlax-true here:
    ....'RemoveNetworkDrive Old :vlax-true :vlax-true)))
    ....'MapNetworkDrive New OldUnc :vlax-true)))
    otherwise changes are not saved in current user profile.

    Cheers
     
    Jürg Menzi, Mar 2, 2005
    #3
  4. Merci vielmal,

    s'hät super g'klappet.

    Es grüssli us Münche,

    Peter
     
    petersciganek, Mar 2, 2005
    #4
  5. Salü Peter

    S'freut mi das i ha chönnä hälfä...¦-)

    Cheers us Oberegg
     
    Jürg Menzi, Mar 2, 2005
    #5
  6. petersciganek

    tditullio Guest

    You can use the DOS "net" command and make two batch files, one to swap O: and L: and one to swap them back. The user could run the one to swap mapped drive letters before accessing the archived files. I would create two shortcuts to the batch files and place on the users' desktops or some easy to access location.

    Use_Archive_Drive.bat
    -------------------------
    rem remove current mappings
    net use O: / delete
    net use L: /delete

    rem create mapped drives
    net use O: \\servername\archive_sharename
    net use L: \\servername\currentprojects_sharename

    Use_Default_Drive.bat
    -------------------------
    rem remove current mappings
    net use O: / delete
    net use L: /delete

    rem create mapped drives
    net use L: \\servername\archive_sharename
    net use O: \\servername\currentprojects_sharename

    I am not sure if the syntax is exactly correct. Go to the command prompt and enter net use /? for the syntax help.
     
    tditullio, Mar 5, 2005
    #6
  7. Thanks - now that I have the function "inside" AutoCAD (with lisp) maybe it will make sense to have a back up batch / exe setup.

    Peter
     
    petersciganek, Mar 7, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.