Monday, 11 October 2010

Map a drive in a Windows BAT file

The following can be used to map a drive in a windows bat file without causing an error when the drive already exists;

REM SETUP MAPPED DRIVE TO Y: IF IT Y: NOT EXIST
if not exist "y:" (net use y: \\myServerName\rootFolderOfMappedDrive)

1 comment:

  1. From a testing and maintenance perspective, this also highlights why documenting and validating infrastructure scripts matters just as much as application code. Treating setup scripts as testable assets and tracking assumptions like mapped drives can prevent subtle environment related failures. Tools like Tuskr test management software are useful for capturing these kinds of setup validations alongside functional tests, especially when working with mixed legacy and modern systems.

    Simple solutions like this age well because they solve real operational problems with minimal complexity.

    ReplyDelete

Thanks for the feedback!