Re: Renaming of mapped network drive lost after end of script
On 8 okt, 10:32, stefaan.van.grunderb...@gmail.com wrote:
> 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 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
|