Home All Groups Group Topic Archive Search About

Renaming of mapped network drive lost after end of script



Author
27 Sep 2007 2:42 PM
scOOBay
Hi All,

I got a problem with some of my workstations to rename mapped network
drives.

I do rename the network drives using VBScript:

objShell.NameSpace(sDrive & "\").Self.Name = sCustomName

My Problem is that the new name is only available when the script is
running.
I put a simple MsgBox at the end of the script. Then I can see the new
name in the
windows explorer until I press OK on the MsgBox.

Can anyone help me regarding this problem?

Thanks a lot!

Regards

Thomas

Author
2 Oct 2007 3:55 PM
Jeff
This works on my network, of course here i use a server/share but i map to AD
namespaces, which works as well

Option Explicit
Dim objNetwork, strDrive, objShell, objUNC
Dim strRemotePath, strDriveLetter, strNewName, strMachineName
Dim strUserName, objUserName
'
on error resume next

' Section to map the network drive
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("Shell.Application")
Set objUserName = CreateObject("WScript.Shell")

' Add Share
strDriveLetter = "O:"
strRemotePath = "\\server\share"
strNewName = "APPS" ' Any alias you decide
objNetwork.RemoveNetworkDrive strDriveLetter
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
objShell.NameSpace(strDriveLetter).Self.Name = strNewName

Show quote
"scOOBay" wrote:

> Hi All,
>
> I got a problem with some of my workstations to rename mapped network
> drives.
>
> I do rename the network drives using VBScript:
>
> objShell.NameSpace(sDrive & "\").Self.Name = sCustomName
>
> My Problem is that the new name is only available when the script is
> running.
> I put a simple MsgBox at the end of the script. Then I can see the new
> name in the
> windows explorer until I press OK on the MsgBox.
>
> Can anyone help me regarding this problem?
>
> Thanks a lot!
>
> Regards
>
> Thomas
>
>
Author
2 Oct 2007 4:00 PM
Jeff
if your "sDrive" is in the form of "D:" then you shouldn't need the & "/"
with it.  Just leave it as "sDrive" and see if it helps.  The script in my
other post works quite well for me, I use it on close to 800 systems.
Show quote
"scOOBay" wrote:

> Hi All,
>
> I got a problem with some of my workstations to rename mapped network
> drives.
>
> I do rename the network drives using VBScript:
>
> objShell.NameSpace(sDrive & "\").Self.Name = sCustomName
>
> My Problem is that the new name is only available when the script is
> running.
> I put a simple MsgBox at the end of the script. Then I can see the new
> name in the
> windows explorer until I press OK on the MsgBox.
>
> Can anyone help me regarding this problem?
>
> Thanks a lot!
>
> Regards
>
> Thomas
>
>
Author
8 Oct 2007 8:32 AM
stefaan.van.grunderbeek
On 27 sep, 16:42, scOOBay <scOO***@gmail.com> wrote:
Show quote
> Hi All,
>
> I got a problem with some of my workstations to rename mapped network
> drives.
>
> I do rename the network drives using VBScript:
>
> objShell.NameSpace(sDrive & "\").Self.Name = sCustomName
>
> My Problem is that the new name is only available when the script is
> running.
> I put a simple MsgBox at the end of the script. Then I can see the new
> name in the
> windows explorer until I press OK on the MsgBox.
>
> Can anyone help me regarding this problem?
>
> Thanks a lot!
>
> Regards
>
> Thomas

I have exactly the same problem! Immedialely after the script ran, the
drives are renemed back to their original names.

Here's the script (ignore the echo's, it's just for debugging ..)
----------------------------------------------------------------------------------------------------------------------
Option Explicit

Dim objNetwork, objShell, coldrives, i

Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Shell.Application")
Set colDrives = objNetwork.EnumNetworkDrives

On error resume next

wscript.echo "Renaming network drives ..."

For i = 0 to colDrives.Count-1 Step 2
    Select Case colDrives.item(i)
    Case "Y:"
    wscript.echo "Y:"
    objShell.NameSpace(colDrives.item(i)).Self.Name = "ServerFolders"
    Case "O:"
    wscript.echo "O:"
    objShell.NameSpace(colDrives.item(i)).Self.Name = "Outlook
Persoonlijke Mappen"
    Case "H:"
    wscript.echo "H:"
    objShell.NameSpace(colDrives.item(i)).Self.Name = "Persoonlijke
Documenten"
    Case "R:"
    wscript.echo "R:"
    objShell.NameSpace(colDrives.item(i)).Self.Name = "Dynaview
Verbinding"
    End Select
Next

If err.number <> 0 then
wscript.echo err.description
End if
------------------------------------------------------------------------------------------------------
Author
8 Oct 2007 12:20 PM
stefaan.van.grunderbeek
On 8 okt, 10:32, stefaan.van.grunderb***@gmail.com wrote:
Show quote
> On 27 sep, 16:42, scOOBay <scOO***@gmail.com> wrote:
>
>
>
>
>
> > Hi All,
>
> > I got a problem with some of my workstations to rename mapped network
> > drives.
>
> > I do rename the network drives using VBScript:
>
> >objShell.NameSpace(sDrive & "\").Self.Name = sCustomName
>
> > My Problem is that the new name is only available when the script is
> > running.
> > I put a simple MsgBox at the end of the script. Then I can see the new
> > name in the
> > windows explorer until I press OK on the MsgBox.
>
> > Can anyone help me regarding this problem?
>
> > Thanks a lot!
>
> > Regards
>
> > Thomas
>
> I have exactly the same problem! Immedialely after the script ran, the
> drives are renemed back to their original names.
>
> Here's the script (ignore the echo's, it's just for debugging ..)
> ---------------------------------------------------------------------------­-------------------------------------------
> Option Explicit
>
> Dim objNetwork, objShell, coldrives, i
>
> Set objNetwork = CreateObject("Wscript.Network")
> Set objShell = CreateObject("Shell.Application")
> Set colDrives = objNetwork.EnumNetworkDrives
>
> On error resume next
>
> wscript.echo "Renaming network drives ..."
>
> For i = 0 to colDrives.Count-1 Step 2
>         Select Case colDrives.item(i)
>         Case "Y:"
>         wscript.echo "Y:"
>        objShell.NameSpace(colDrives.item(i)).Self.Name = "ServerFolders"
>         Case "O:"
>         wscript.echo "O:"
>        objShell.NameSpace(colDrives.item(i)).Self.Name = "Outlook
> Persoonlijke Mappen"
>         Case "H:"
>         wscript.echo "H:"
>        objShell.NameSpace(colDrives.item(i)).Self.Name = "Persoonlijke
> Documenten"
>         Case "R:"
>         wscript.echo "R:"
>        objShell.NameSpace(colDrives.item(i)).Self.Name = "Dynaview
> Verbinding"
>         End Select
> Next
>
> If err.number <> 0 then
> wscript.echo err.description
> End if
> ---------------------------------------------------------------------------­---------------------------- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

after some more testing, I found out the following:

- the script actually works. It's just that after the script ends, the
old names come back. Putting a wscript.sleep 30000 keeps the correct
drivenames for 30 secs.
- my workstation seems to be the only workstation that doesn't have
this problem, all (200) others do...
- I tried with local admin credentials, without any change

the updated testing script:

'This script will rename network drives to something more fool-proof
'Drive Y will be named 'ServerFolders'
'Drive O will be named 'Outlook Data Files'
'Drive H will be named 'Persoonlijke Documenten'
'Note: this should run after network drives have been mapped ...

Option Explicit

Dim objNetwork, objShell, coldrives, i

Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Shell.Application")
Set colDrives = objNetwork.EnumNetworkDrives

On error resume next

wscript.echo "Renaming network drives ..."

For i = 0 to colDrives.Count-1 Step 2
    Select Case colDrives.item(i)

    Case "Y:"
    wscript.echo "old name Y: " &
objShell.NameSpace(colDrives.item(i)).Self.Name
    objShell.NameSpace(colDrives.item(i)).Self.Name = "ServerFolders"
    wscript.echo "new name for Y :" &
objShell.NameSpace(colDrives.item(i)).Self.Name

    Case "O:"
    wscript.echo "old name O :" &
objShell.NameSpace(colDrives.item(i)).Self.Name
    objShell.NameSpace(colDrives.item(i)).Self.Name = "Outlook
Persoonlijke Mappen"
    wscript.echo "new name for O :" &
objShell.NameSpace(colDrives.item(i)).Self.Name


    Case "H:"
    wscript.echo "old name H :" &
objShell.NameSpace(colDrives.item(i)).Self.Name
    objShell.NameSpace(colDrives.item(i)).Self.Name = "Persoonlijke
Documenten"
    wscript.echo "new name for H :" &
objShell.NameSpace(colDrives.item(i)).Self.Name


    Case "R:"
    wscript.echo "old name R: " &
objShell.NameSpace(colDrives.item(i)).Self.Name
    objShell.NameSpace(colDrives.item(i)).Self.Name = "Dynaview
Verbinding"
    wscript.echo "new name for R: " &
objShell.NameSpace(colDrives.item(i)).Self.Name
    End Select

Next

wscript.sleep 20000

If err.number <> 0 then
wscript.echo err.description
End if

AddThis Social Bookmark Button