0windows 8 logoscript to create and name network shares

When updat­ing or repla­cing a home PC I use Win­dows Deploy­ment Ser­vices (WDS) to rein­stall Win­dows. It means I only have to main­tain a single up-to-date source for all the little free apps I use (Fire­fox, 7zip, Kodi, etc) and makes a new setup much more pain­less. One of the few bugs that has irrit­ated me for ages is the net­work drive map that I cre­ate has always had to be renamed manually.

I think the prob­lem stems from the need for admin rights when renam­ing a drive. Whilst I can run the rename com­mand as an admin­is­trat­or this seems to fail as the share isn’t present for the admin account, only for the user account. What I would need to do is run the com­mand as the user and then elev­ate it. I don’t know of any script­ing way to do this, so the nor­mal rename com­mand seems a dead loss.

The good news is that there is a way to do the rename via the registry, and registry changes can eas­ily be made from the com­mand line. To map and rename a share requires just 2 commands

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##serv­er-name#share-name /v _LabelFromReg /t REG_SZ /f /d “Name to use for share

net use y: \\serv­er-name\share-name /user:serv­er-name\user­name pass­word /persistent:yes

This can be put in a simple batch file and duplic­ate for each share you want to map. Viola — no more ugly names for net­work shares

Αφήστε μια απάντηση