Bonjour,
La méthode de rediriger via script n'est pas la meilleure et ne permet pas un fonctionnement correct des PC portables pouvant travailler en session déconnectée.
La bonne pratique est de passer par GPO.
Il faut donc ne pas appeler la routine de redirection.
Vous utilisez un script trop ancien ou il difficile de discerner les différents modules.
Si vous utilisez KoXo Profiles et voulez que les administrateurs maitrisent le bureau il faut alors ne pas toucher à cette redirection là.
Voici les scripts scolaires actuels :
Code:
'--------------------------------------------------------------------------------------------------------------------------
'(c) 2006-2015 KoXo Dev. Script VBS "Elèves 4"
'--------------------------------------------------------------------------------------------------------------------------
'Unmap existing drives
UnconnDrives
Set UserObj=FindUser
If Not IsEmpty(UserObj) Then
'Map Home Drive
ConnectDrive UserObj.HomeDirDrive,UserObj.HomeDirectory,"Espace personnel de "+UserObj.fullName
'Folders redirection (remove next line if managed with GPO)
'Redirections UserObj.HomeDirDrive
End If
'Map Group Drive
ConnectDrive "%GROUP_DRIVE%","\\%SECONDARY_GROUP_SERVER%\%SECONDARY_GROUP%$","Ma classe [%SECONDARY_GROUP%]"
'Remove next quote to display user and computer informations on the wallpaper
Execute GetLogonServer+"\NETLOGON\Wallpaper.vbs /BackGroundColor=#A56E3A"
'End
WScript.Quit
'--------------------------------------------------------------------------------------------------------------------------
'///////////
'// Execute
function execute(CommandLine)
On Error Resume Next
Dim oShell
Set oShell=CreateObject("WScript.Shell")
err.Number=0
oShell.Run CommandLine,1,True
If err.number<>0 Then
oShell.Popup "Execution : " & CommandLine & VbCrLf & "Description=" & err.Description & VbCrLf & "Code=" & err.Number,5,"Erreur",64
End If
end function
'////////////////
'// Redirections
function Redirections(Drive)
On Error Resume Next
Dim oShell
Dim Reg,BaseReg,ExcludeProfileDirs
Set oShell=CreateObject("WScript.Shell")
BaseReg="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\"
Reg=oShell.RegWrite(BaseReg+"Personal",Drive+"\Documents","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"Favorites",Drive+"\Favorites","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"My Pictures",Drive+"\Pictures","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"My Music",Drive+"\Music","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"My Video",Drive+"\Videos","REG_SZ")
'Reg=oShell.RegWrite(BaseReg+"Desktop",Drive+"\Desktop","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{374DE290-123F-4565-9164-39C4925E467B}",Drive+"\Downloads","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}",Drive+"\Links","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}",Drive+"\Searches","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{56784854-C6CB-462B-8169-88E350ACB882}",Drive+"\Contacts","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}",Drive+"\Saved Games","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"Templates",Drive+"\CONFIG\Templates","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"History",Drive+"\CONFIG\History","REG_SZ")
'Reg=oShell.RegWrite(BaseReg+"AppData",Drive+"\CONFIG\Application Data","REG_SZ")
'Reg=oShell.RegWrite(BaseReg+"Cookies",Drive+"\CONFIG\Cookies","REG_SZ")
'ExcludeProfileDirs="HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\ExcludeProfileDirs"
'Reg=oShell.RegWrite(ExcludeProfileDirs,"Mes Documents;Favoris;Bureau;Menu démarrer;Application Data;Cookies;Modèles","REG_SZ")
End function
'////////////////////////////////
'// Unconnect all network drives
function UnconnDrives()
On Error Resume Next
Dim objNetwork
Dim i,colDrives
Set objNetwork=WScript.CreateObject("WScript.Network")
'Unmap existing drives
Set colDrives=objNetwork.EnumNetworkDrives
If colDrives.Count<>0 Then
For i=0 To colDrives.Count-1 Step 2
objNetwork.RemoveNetworkDrive colDrives(i),"True","True"
Next
End If
End function
'/////////////////////
'// Find a user in AD
function FindUser()
On Error Resume Next
Dim objNetwork,oScriptShell
Dim strUserName,strUserDomain,sUserObj
Dim i,UserObj
Set objNetwork=WScript.CreateObject("WScript.Network")
Set oScriptShell=CreateObject("WScript.Shell")
strUserName=objNetwork.UserName
strUserDomain=objNetwork.UserDomain
sUserObj="WinNT://" & strUserDomain & "/" & strUserName
i=0
Do
i=i+1
Set UserObj=GetObject(sUserObj)
If UserObj Is Nothing Then WScript.Sleep 1000 End If
Loop While (i<20) And IsEmpty(UserObj)
If UserObj Is Nothing Then
oScriptShell.Popup "Impossible de trouver : " & sUserObj,5,"Erreur GetObject",64
End If
Set FindUser=UserObj
End function
'///////////////////
'// Connect a drive
function ConnectDrive(Drive,Path,Description)
On Error Resume Next
Dim objNetwork,oScriptShell
Set objNetwork=WScript.CreateObject("WScript.Network")
Set oScriptShell=CreateObject("WScript.Shell")
Set oShell=CreateObject("Shell.Application")
err.number=0
objNetwork.MapNetworkDrive Drive,Path
If err.number<>0 Then
oScriptShell.Popup "Connexion lecteur " & Drive & " (" & Path & ")" & VbCrLf & "Description=" & err.Description & VbCrLf & "Code=" & err.Number,5,"Erreur",64
Else
oShell.NameSpace(Drive).Self.Name=Description
End If
end function
'//////////////////////
'// Get the LogonServer
function GetLogonServer()
Dim objShell
Set objShell=Wscript.CreateObject("Wscript.Shell")
GetLogonServer=objShell.ExpandEnvironmentStrings("%LOGONSERVER%")
End Function
Code:
'--------------------------------------------------------------------------------------------------------------------------
'(c) 2006-2015 KoXo Dev. Script VBS "Professeurs 4"
'--------------------------------------------------------------------------------------------------------------------------
'Unmap existing drives
UnconnDrives
Set UserObj=FindUser
If Not IsEmpty(UserObj) Then
'Map Home Drive
ConnectDrive UserObj.HomeDirDrive,UserObj.HomeDirectory,"Espace personnel de "+UserObj.fullName
'Folders redirection (remove next line if managed with GPO)
'Redirections UserObj.HomeDirDrive
End If
'Map Group Drives
ConnectDrive "%GROUP_DRIVE%","\\%SECONDARY_GROUP_SERVER%\%SECONDARY_GROUP%$","Ma discipline [%SECONDARY_GROUP%]"
ConnectDrive "R:","\\%SERVER[1]%\Eleves$","Espaces personnels des élèves"
ConnectDrive "S:","\\%SERVER[1]%\Classes$","Espaces communs des classes"
'Remove next quote to display user and computer informations on the wallpaper
Execute GetLogonServer+"\NETLOGON\Wallpaper.vbs /BackGroundColor=#808080"
'End
WScript.Quit
'--------------------------------------------------------------------------------------------------------------------------
'///////////
'// Execute
function execute(CommandLine)
On Error Resume Next
Dim oShell
Set oShell=CreateObject("WScript.Shell")
err.Number=0
oShell.Run CommandLine,1,True
If err.number<>0 Then
oShell.Popup "Execution : " & CommandLine & VbCrLf & "Description=" & err.Description & VbCrLf & "Code=" & err.Number,5,"Erreur",64
End If
end function
'////////////////
'// Redirections
function Redirections(Drive)
On Error Resume Next
Dim oShell
Dim Reg,BaseReg,ExcludeProfileDirs
Set oShell=CreateObject("WScript.Shell")
BaseReg="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\"
Reg=oShell.RegWrite(BaseReg+"Personal",Drive+"\Documents","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"Favorites",Drive+"\Favorites","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"My Pictures",Drive+"\Pictures","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"My Music",Drive+"\Music","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"My Video",Drive+"\Videos","REG_SZ")
'Reg=oShell.RegWrite(BaseReg+"Desktop",Drive+"\Desktop","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{374DE290-123F-4565-9164-39C4925E467B}",Drive+"\Downloads","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}",Drive+"\Links","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}",Drive+"\Searches","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{56784854-C6CB-462B-8169-88E350ACB882}",Drive+"\Contacts","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}",Drive+"\Saved Games","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"Templates",Drive+"\CONFIG\Templates","REG_SZ")
Reg=oShell.RegWrite(BaseReg+"History",Drive+"\CONFIG\History","REG_SZ")
'Reg=oShell.RegWrite(BaseReg+"AppData",Drive+"\CONFIG\Application Data","REG_SZ")
'Reg=oShell.RegWrite(BaseReg+"Cookies",Drive+"\CONFIG\Cookies","REG_SZ")
'ExcludeProfileDirs="HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\ExcludeProfileDirs"
'Reg=oShell.RegWrite(ExcludeProfileDirs,"Mes Documents;Favoris;Bureau;Menu démarrer;Application Data;Cookies;Modèles","REG_SZ")
End function
'////////////////////////////////
'// Unconnect all network drives
function UnconnDrives()
On Error Resume Next
Dim objNetwork
Dim i,colDrives
Set objNetwork=WScript.CreateObject("WScript.Network")
'Unmap existing drives
Set colDrives=objNetwork.EnumNetworkDrives
If colDrives.Count<>0 Then
For i=0 To colDrives.Count-1 Step 2
objNetwork.RemoveNetworkDrive colDrives(i),"True","True"
Next
End If
End function
'/////////////////////
'// Find a user in AD
function FindUser()
On Error Resume Next
Dim objNetwork,oScriptShell
Dim strUserName,strUserDomain,sUserObj
Dim i,UserObj
Set objNetwork=WScript.CreateObject("WScript.Network")
Set oScriptShell=CreateObject("WScript.Shell")
strUserName=objNetwork.UserName
strUserDomain=objNetwork.UserDomain
sUserObj="WinNT://" & strUserDomain & "/" & strUserName
i=0
Do
i=i+1
Set UserObj=GetObject(sUserObj)
If UserObj Is Nothing Then WScript.Sleep 1000 End If
Loop While (i<20) And IsEmpty(UserObj)
If UserObj Is Nothing Then
oScriptShell.Popup "Impossible de trouver : " & sUserObj,5,"Erreur GetObject",64
End If
Set FindUser=UserObj
End function
'///////////////////
'// Connect a drive
function ConnectDrive(Drive,Path,Description)
On Error Resume Next
Dim objNetwork,oScriptShell
Set objNetwork=WScript.CreateObject("WScript.Network")
Set oScriptShell=CreateObject("WScript.Shell")
Set oShell=CreateObject("Shell.Application")
err.number=0
objNetwork.MapNetworkDrive Drive,Path
If err.number<>0 Then
oScriptShell.Popup "Connexion lecteur " & Drive & " (" & Path & ")" & VbCrLf & "Description=" & err.Description & VbCrLf & "Code=" & err.Number,5,"Erreur",64
Else
oShell.NameSpace(Drive).Self.Name=Description
End If
end function
'//////////////////////
'// Get the LogonServer
function GetLogonServer()
Dim objShell
Set objShell=Wscript.CreateObject("Wscript.Shell")
GetLogonServer=objShell.ExpandEnvironmentStrings("%LOGONSERVER%")
End Function
Cdt
Le support