a long time ago, I had to rename a lot of drive mappings on a lot of PCs - this is how I did it, knowing full well there are better ways to do it.
######################## ### make_map_bat.pl ### ###################### print " Drive Share Mapper\n"; print "--------------------\n"; print "If you just want to create a new share - just press\n"; print "enter for the first two questions\n\n"; print "What server is your share currently mapped to: "; $current_server=<stdin>; chomp ($current_server); print "What is the name of the current share: "; $current_share=<stdin>; chomp ($current_share); unless ( `net view $current_server|grep $current_share`) { print "\\\\ +$current_server\\\\$current_share does not exist!\n\n" } print "What drive letter is this share currently using: "; $drive_letter=<stdin>; chomp ($drive_letter); print "What server is the new share on: "; $new_server=<stdin>; chomp ($new_server); print "What is the name of the new share: "; $new_share=<stdin>; chomp ($new_share); unless ( `net view $new_server|grep $new_share`) { print "\\\\$new_ser +ver\\\\$new_share does not exist!\n\n" } open (BATCHFILE, ">c:\\$new_share.bat") || die "Cannot open file for w +riting: $!\n"; unless ( $current_server eq "" ) { print BATCHFILE "REM *** DELETE OLD SHARE ***\n"; print BATCHFILE "net use $drive_letter: \/delete\n"; } print BATCHFILE "REM *** ADD A NEW PERSISTENT SHARE ***\n"; print BATCHFILE "net use $drive_letter: \\\\$new_server\\$new_share \/ +persistent:yes\n"; close BATCHFILE; print "\n\n"; print "A file named $new_share.bat has been placed in C:\\\n";

In reply to drive share batch file writer for win32 by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.