다른 PC의 공유폴더를 네트워크 드라이브로 연결해서 사용하는 경우가 종종 있다.
보안, 바이러스의 문제로 인해 대부분 비밀번호를 설정해두는데 번번히 비밀번호를 입력하고 연결하는게 매우 귀찮은 일이다.
이 경우 VBScript를 이용하면 쉽게 연결 가능하다.
메모장을 이용해서 아래 소스의 IP, User, Password 변경 후 "NetworkDrive.vbs" 파일로 저장한다.
그리고 "NetworkDrive.vbs" 파일을 더블클릭(실행)하면 네트워크 드라이브가 연결된다.
Option Explicit
Dim WshNetwork
Dim StrLocalDrive
Dim StrRemotePath
Dim BlnLogProfile
Dim StrUser
Dim StrPassword
StrLocalDrive = "Z:" ' 연결 드라이브명
StrRemotePath = "\\192.168.1.100\Shared" ' 공유이름
BlnLogProfile = False ' User Profile에 연결 정보 저장여부
StrUser = "UserID" ' 공유 사용자 ID
StrPassword = "Password" ' 공유 사용자 비밀번호
On Error Resume Next
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive StrLocalDrive
Set WshNetwork = nothing
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive StrLocalDrive, StrRemotePath, BlnLogProfile, StrUser, StrPassword
Set WshNetwork = nothing
Dim WshNetwork
Dim StrLocalDrive
Dim StrRemotePath
Dim BlnLogProfile
Dim StrUser
Dim StrPassword
StrLocalDrive = "Z:" ' 연결 드라이브명
StrRemotePath = "\\192.168.1.100\Shared" ' 공유이름
BlnLogProfile = False ' User Profile에 연결 정보 저장여부
StrUser = "UserID" ' 공유 사용자 ID
StrPassword = "Password" ' 공유 사용자 비밀번호
On Error Resume Next
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive StrLocalDrive
Set WshNetwork = nothing
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive StrLocalDrive, StrRemotePath, BlnLogProfile, StrUser, StrPassword
Set WshNetwork = nothing
댓글을 달아 주세요