본문 바로가기

프로그램 경험/운영체제

[윈도우] 네트워크 드라이브 이름 수정하기

회사에서 네트워크 드라이브를 많이 붙여서 사용한다.

그런데 네트워크 드라이브 이름이 주소까지 다 붙어서 표시 되기 때문에 가독성이 떨어진다.


이름바꾸기를 통해서 이름을 바꾸려 하면 새문자 입력은 안되고 수정만 가능하다.

방법을 검색해 보니 VBScript로 해결하신 분들이 있다.


아래 내용 참고해서 사용하면 쉽게 해결된다.



원문 : http://social.technet.microsoft.com/Forums/ko-KR/windowsserverko/thread/ddee6508-c311-4542-b41f-07526f5630e8

-------------------------------------------

안녕하세요

Vbscript로 한방에 해결 할 수 있습니다.

아래의 script를 참조하시고 실행방법은 command창에서 C:\>test.vbs (batch파일 실행과 동일)

'--//==========================================
' Rename network drive (NameDrive.vbs)
'--//==========================================
Option Explicit
Dim objNetwork, strDrive, objShell, objUNC
Dim strRemotePath, strDriveLetter, strNewName

 

strDriveLetter = "W:"    'Network Drive name
strRemotePath = "\\host\sharedfolder_name"    'shared folder name
strNewName = "abcd"   '원하시는 이름으로

 

' Section to map the network drive
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter).Self.Name = strNewName

 

'Wscript.Echo "Check : "& strDriveLetter & " for " & strNewName
'WScript.Quit

' End of Example VBScript.


-------------------------------------------


감사합니다. 말끔하게 해결봤습니다.

배열을 이용해 네트워크 드라이브를 연결/해제할 수 있도록 수정해봤습니다.

 

'--//==========================================
' Control network drive (NetDrive.vbs)
'--//==========================================
Option Explicit
Dim objNetwork, objShell, i, blnConnect

 

 

'Start Config

 

Dim aryNetDrive(3,6)    'set number of network drive   aryNetDrive('Number Of Network Drive, 6)

blnConnect = True    'map the network drive
'blnConnect = False    'remove network drive

 

aryNetDrive(0,0) = "L:"    'Network Drive name
aryNetDrive(0,1) = "\\host\sharedfolder_name"    'shared folder name
aryNetDrive(0,2) = "sharedfolder_name"    'rename network drive
aryNetDrive(0,3) = False    'use other user
aryNetDrive(0,4) = False    'save account infomation
aryNetDrive(0,5) = ""    'other user id
aryNetDrive(0,6) = ""    'other user password

 

aryNetDrive(1,0) = "M:"    'Network Drive name
aryNetDrive(1,1) = "\\host\sharedfolder_name"    'shared folder name
aryNetDrive(1,2) = "sharedfolder_name"    'rename network drive
aryNetDrive(1,3) = false    'use other user

 

aryNetDrive(2,0) = "N:" 

aryNetDrive(2,1) = "\\host\sharedfolder_name

aryNetDrive(2,2) = "sharedfolder_name" 

aryNetDrive(2,3) = false 

 

'End Config

 

 

Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("Shell.Application") 
For i = 0 To UBound(aryNetDrive, 1) -1
 If blnConnect Then
  'Section to map the network drive
  If aryNetDrive(i,3) Then
   objNetwork.MapNetworkDrive aryNetDrive(i,0), aryNetDrive(i,1), aryNetDrive(i,4), aryNetDrive(i,5), aryNetDrive(i,6)
  Else
   objNetwork.MapNetworkDrive aryNetDrive(i,0), aryNetDrive(i,1)
  End If
  'Section which actually (re)names the Mapped Drive
  objShell.NameSpace(aryNetDrive(i,0)).Self.Name = aryNetDrive(i,2)
 Else
  'Section to remove network drive
  objNetwork.RemoveNetworkDrive aryNetDrive(i,0)
End If
Next 
 

'On Error Resume Next
'Wscript.Echo "Error # " & CStr(Err.Number) & " " & Err.Description
'Err.Clear

 

'WScript.Quit