Jump to content

johnhlaj

Member
  • Posts

    1
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

About johnhlaj

johnhlaj's Achievements

0

Reputation

  1. I have been using a windows scripting host script and it seems to work. Here is the code I have been using for this: paste this into notepad and rename it to map.vbs or whatever you want. It should do the trick. For my needs I have it clearing all network connections each time it runs and mapping one drive to Z it works for what I need. 'Map a network drive of your choice 'Created by John Hlaj 'Jan 28, 2007 Option Explicit Dim objNetwork Dim i, clDrives, WSHNetwork, strDriveLetter, strRemotePath ,strUserName, strPassword , strProfile 'Disconnect ALL mapped drives Set WSHNetwork = CreateObject("WScript.Network") Set clDrives = WshNetwork.EnumNetworkDrives For i = 0 to clDrives.Count -1 Step 2 WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True Next 'Give the PC time to do the disconnect, wait 300 milliseconds wscript.sleep 300 'Set drive to Z and request remote path strDriveLetter = "Z:" strRemotePath = InputBox("Enter remote path eg. \\server\share", "Map Network Drive by John Hlaj") if IsEmpty(strRemotePath) then Wscript.Quit end if strUserName = InputBox("Enter user name.", "Map Network Drive by John Hlaj") if IsEmpty(strUserName) then Wscript.Quit end if strPassword = InputBox("Enter password.", "Map Network Drive by John Hlaj") if IsEmpty(strPassword) then Wscript.Quit end if strProfile = "false" ' Creates a network object ' Then to apply the MapNetworkDrive method. Set objNetwork = CreateObject("WScript.Network") objNetwork.MapNetworkDrive strDriveLetter, strRemotePath , strProfile, strUserName, strPassword ' Extra code just to add a message box WScript.Echo strRemotePath & " mapped to: " & strDriveLetter WScript.Quit
×
×
  • Create New...