1

I'm trying to create a batch file using windows powershell that will look for existing persistent network shares and take their path to create a name, much like a custom disk label.

I'm a novice but know the start point can be based on the following, although this needs taking a step further to look for existing shares, to run on stratup, and to be executable each time a new share is added.

Thanks,

$Net = New-Object -ComObject WScript.Network  
$Rename = New-Object -ComObject Shell.Application  

#### # Map the local drives  
Subst Q: 'C:\File Path\Uno'    
Subst U: 'C:\File Path\Dos' 

#### # Map the network drives  
$Net.MapNetworkDrive("X:", '\\Server\File Path\Uno')  
$Net.MapNetworkDrive("Y:", '\\Different Server\File Path\Dos')

#### # Rename everything  
$rename.NameSpace("Q:\").Self.Name = 'Network -> FOO'  
$rename.NameSpace("U:\").Self.Name = 'Network -> BAR'  
$rename.NameSpace("X:\").Self.Name = 'Local -> FOO'  
$rename.NameSpace("Y:\").Self.Name = 'Local -> BAR'

my rational follows similarly on from: Naming a Drive with a Batch File

This is my first post here and I'm grateful for any assistance.

Community
  • 1
  • 1
Ogriff
  • 41
  • 1
  • 3

1 Answers1

0

Use Symbolic Links instead :

mklink /d c:\foo \\foo\bar
Turrican
  • 607
  • 4
  • 9