Results 1 to 11 of 11

Thread: vb script add, remove, rename network drive help

  1. #1
    Aria Resident cinek's Avatar
    Join Date
    Nov 2010
    Location
    London
    Posts
    3,390
    Thanks
    644
    Thanked 184 Times in 152 Posts
    Rep Power
    1

    Default vb script add, remove, rename network drive help

    I'm trying to check if a drive exists, if it does I need to remove it and rename as the old name sticks for some reason. This is what I have right now:

    Code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")Set objNetwork = CreateObject("Wscript.Network")
    
    
    if objFSO.folderexists("O:") then
    	objNetwork.RemoveNetworkDrive "O:", True, True
    	objNetwork.MapNetworkDrive "O:", "\\srv-fs\shares"
    	
    	set renameShell = createObject("shell.application")
    	mappedDrive = "O:\"
    	renameShell.nameSpace(mappedDrive).self.name = "Shares (\\srv-fs-shares)"
    End If
    it changes the path but the old name stays for some reason - any ideas?
    3770k | MSI Twin Frozr GTX570 | Mushkin Blackline 16GB | Noctua NH-D14 | Samsung 840 Pro 128GB | Crucial M4 128GB | Gigabyte P67A-UD4-B3 | SoundBlaster X-Fi Fatal1ty Pro | Corsair AX850 | Fractal Design R3

  2. #2

    Join Date
    Feb 2010
    Posts
    345
    Thanks
    8
    Thanked 34 Times in 30 Posts
    Rep Power
    1

    Default

    The name you are setting via your script would be stored in the registry. Ini files can also store drive labels, e.g.desktop.ini. Check these?

  3. #3
    Aria Resident cinek's Avatar
    Join Date
    Nov 2010
    Location
    London
    Posts
    3,390
    Thanks
    644
    Thanked 184 Times in 152 Posts
    Rep Power
    1

    Default

    Nope haven't checked those. But if the drive is removed why would the old entry still be present in the .ini file or the registry?
    3770k | MSI Twin Frozr GTX570 | Mushkin Blackline 16GB | Noctua NH-D14 | Samsung 840 Pro 128GB | Crucial M4 128GB | Gigabyte P67A-UD4-B3 | SoundBlaster X-Fi Fatal1ty Pro | Corsair AX850 | Fractal Design R3

  4. #4
    /dev/null Plan9's Avatar
    Join Date
    Aug 2011
    Location
    /root/
    Posts
    2,291
    Thanks
    315
    Thanked 253 Times in 197 Posts
    Rep Power
    1

    Default

    It's been a while since I've done this in VBS, but it sounds to me like a Windows bug. Restart explorer.exe to see if the name is persistent.

  5. #5
    Aria Resident cinek's Avatar
    Join Date
    Nov 2010
    Location
    London
    Posts
    3,390
    Thanks
    644
    Thanked 184 Times in 152 Posts
    Rep Power
    1

    Default

    nope, still the same
    3770k | MSI Twin Frozr GTX570 | Mushkin Blackline 16GB | Noctua NH-D14 | Samsung 840 Pro 128GB | Crucial M4 128GB | Gigabyte P67A-UD4-B3 | SoundBlaster X-Fi Fatal1ty Pro | Corsair AX850 | Fractal Design R3

  6. #6

    Join Date
    Feb 2010
    Posts
    345
    Thanks
    8
    Thanked 34 Times in 30 Posts
    Rep Power
    1

    Default

    Quote Originally Posted by cinek View Post
    Nope haven't checked those. But if the drive is removed why would the old entry still be present in the .ini file or the registry?
    Windows remembers any drives that have been mapped or connected.

    The machine I am on right now is Vista so might be different for you, take a look at HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer\MountPoints2

  7. #7
    Aria Resident cinek's Avatar
    Join Date
    Nov 2010
    Location
    London
    Posts
    3,390
    Thanks
    644
    Thanked 184 Times in 152 Posts
    Rep Power
    1

    Default

    the strange thing is, the drive dissapears after I restart my pc
    3770k | MSI Twin Frozr GTX570 | Mushkin Blackline 16GB | Noctua NH-D14 | Samsung 840 Pro 128GB | Crucial M4 128GB | Gigabyte P67A-UD4-B3 | SoundBlaster X-Fi Fatal1ty Pro | Corsair AX850 | Fractal Design R3

  8. #8

    Join Date
    Feb 2010
    Posts
    345
    Thanks
    8
    Thanked 34 Times in 30 Posts
    Rep Power
    1

    Default

    Quote Originally Posted by cinek View Post
    the strange thing is, the drive dissapears after I restart my pc
    As in the drive mapping is not a persistent mapping?

    Even if the drives is not shown as mapped, the registry holds information about it including drives such as USB memory sticks.

  9. #9
    Aria Resident cinek's Avatar
    Join Date
    Nov 2010
    Location
    London
    Posts
    3,390
    Thanks
    644
    Thanked 184 Times in 152 Posts
    Rep Power
    1

    Default

    Quote Originally Posted by Hax View Post
    As in the drive mapping is not a persistent mapping?

    Even if the drives is not shown as mapped, the registry holds information about it including drives such as USB memory sticks.
    yeah, when I map the drive by running the script manually, it doesn't stay map the next time I turn on the pc ;/
    3770k | MSI Twin Frozr GTX570 | Mushkin Blackline 16GB | Noctua NH-D14 | Samsung 840 Pro 128GB | Crucial M4 128GB | Gigabyte P67A-UD4-B3 | SoundBlaster X-Fi Fatal1ty Pro | Corsair AX850 | Fractal Design R3

  10. #10

    Join Date
    Feb 2010
    Posts
    345
    Thanks
    8
    Thanked 34 Times in 30 Posts
    Rep Power
    1

    Default

    Quote Originally Posted by cinek View Post
    yeah, when I map the drive by running the script manually, it doesn't stay map the next time I turn on the pc ;/
    Then change this line to:

    objNetwork.MapNetworkDrive "O:", "\\srv-fs\shares", True

  11. The Following User Says Thank You to Hax For This Useful Post:


  12. #11
    Aria Resident cinek's Avatar
    Join Date
    Nov 2010
    Location
    London
    Posts
    3,390
    Thanks
    644
    Thanked 184 Times in 152 Posts
    Rep Power
    1

    Default

    thanks, I'll try that on Monday
    3770k | MSI Twin Frozr GTX570 | Mushkin Blackline 16GB | Noctua NH-D14 | Samsung 840 Pro 128GB | Crucial M4 128GB | Gigabyte P67A-UD4-B3 | SoundBlaster X-Fi Fatal1ty Pro | Corsair AX850 | Fractal Design R3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •