Script vbs autoconfiguration outlook

crunchattak59 Messages postés 5 Date d'inscription vendredi 9 février 2007 Statut Membre Dernière intervention 21 mars 2007 - 9 févr. 2007 à 15:40
phil_iiep Messages postés 1 Date d'inscription samedi 23 juillet 2005 Statut Membre Dernière intervention 13 décembre 2008 - 13 déc. 2008 à 13:56
Bonjour à toute et à tous,

Voila mon probleme:

J'ai vu sur internet que l'on pouvait autoconfigurer outlook avec le fichier richprofile...

Ils disent sur leur site de faire un script... Etant plus dans le réseau je dois vous avouez que je ne connais pas une seul commande en vbs...

Donc, après quelques recherches sur internet, je trouve cela:

option explicit
on error resume next


' Declare the variables
dim wshNet, wshShell, userName,UserObj, DomainName,ProfileOutlook,ObjFs,testcle,ServeurExchange


dim strcomputer,Arrvalues,CleReg,ObjRegistry


' Create a WshNet object
set wshNet = createObject("wscript.Network")


' Create a wshShell object
set wshShell = createObject("wscript.shell")


' Create an Object File System object
SET objFS=CreateObject ("Scripting.FileSystemObject")


Const HKEY_CURRENT_USER = &H80000001 
strComputer = "."
Set objRegistry = GetObject("winmgmts:\" & strComputer & "\root\default:StdRegProv") 


UserName=WshNet.username
ServeurExchange="srv_exchange"




' Config Outlook
If objfs.fileexists(WshShell.ExpandEnvironmentStrings("%systemroot%")+"\fonts\outlook.ttf") Then
  TestCle=WshShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"+username+"\0a0d020000000000c000000000000046\000b0340")
  If Err.number<>0 Then
    Err.clear
    ProfileOutlook=WshShell.ExpandEnvironmentStrings("%logonserver%")+"\NETLOGON\richProfile "+ServeurExchange+" "+ username+" "+ username
'  msgbox(ProfileOutlook)
    wshShell.run ProfileOutlook,,true


'Affectation du cache local
    arrValues = Array(132,5,0,0)
    CleReg="Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"+username+"\13dbb0c8aa05101a9bb000aa002fc45a"
    objRegistry.SetBinaryValue HKEY_CURRENT_USER, CleReg, "00036601", arrValues


  Else
    wscript.echo "Le profile outlook existe!"
  End If
else
  wscript.echo "Pas de outlook"
End IF


Voila le seul probleme c'est qu'il ne marche pas...

Et je ne sais pas pourquoi... On m'a dit que c'était un problème avec "+" qu'il fallait remplacé par les "&" et mettre des espaces...
Mais j'ai essayé plusieurs choses mais ca ne marche pas...

Pour résumer voila ce que je souhaiterais:

Si il existe le fichier extend.dat dans C:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook\
Alors arrete le vbs sans message...

Si il n'existe pas: lancer la commande %logonserver%\netlogon\richprofile.exe srv_echange %username% %username%

Il faut savoir que pour la commande DOS pour richprofile c'est : richprofile.exe srv_exchange %username% %username%...

Est ce qu'il y aurait une âme charitable pour me faire ce petit fichier vbs?

A si vous pourriez faire quelque chose pour moi, car sans exagéré cela fais plus de dix jour que je planche dessus et je sèche... 

Un grand merci part avance...

Crunch

4 réponses

cs_MPi Messages postés 3877 Date d'inscription mardi 19 mars 2002 Statut Membre Dernière intervention 17 août 2018 23
10 févr. 2007 à 13:01
Je ne saurais t'aider pour le Script, mais une question qui me vient à l'esprit...
Est-ce que Server Exchange est installé sur ta machine et fonctionnel ?
Et as-tu une idée où ça "plante" ?

MPi
0
crunchattak59 Messages postés 5 Date d'inscription vendredi 9 février 2007 Statut Membre Dernière intervention 21 mars 2007
12 févr. 2007 à 08:12
Je fais partis d'une entreprise... Et oui je peux vous assuerez qu'il est focntionnel...

Oui je crois que dans le script il recherche une clef de registre et il faut rechercher un fichier...

Crunch
0
Gojir4 Messages postés 7 Date d'inscription mercredi 17 mai 2006 Statut Membre Dernière intervention 7 juillet 2009
3 nov. 2008 à 08:19
Hello,

Voici une solution possible avec RichProfile. Je l'utilise pour configurer les comptes dans mon entreprise.
Par contre l'utilisateur doit encore choisir son nom dans une liste avant de lancer Outlook car RichProfile utilise le username et non pas le nom complet. (même en lui donnant le nom complet)

Voici mon code, Il contient3 fonctions.

GetFullUserName qui renvoi le nom complet (ex: "Pignon, Jean-Marc") de l'utilisateur loggué en cours
OutlookProfilIsSet qui vérifie si un profil outlook existe déjà
SetOutlook qui Lance Richprofile au cas ou il n'y a pas encore de profil  installé (à toi de modifier selon tes besoins)

Il n'y a pas de gestion d'erreur je ne maitrise encore pas bien cela.

'Constantes :
' Objet WMI
        const strComputer                = "." 'utilsé lors de création d'objet WMI.
'       Outlook :
        const strServeurExchange       = "ADRESSE_SERVEUR_EXCHANGE"
        const strRegOutlookProfilePath = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile"
        const OutlookNoProfil                  = 0   
        const OutlookProfilExist              = 1
        const OutlookNotInstalled             = 2

'Récupération du nom complet de l'utilisateur
Function GetFullUserName
    Dim WshShell, WshEnv, objFSO, WshNetwork, DomainString, UserString, strUser
    Dim objSysInfo, objDomain, objCurrentUser, UserObj, objUser
    Const OverwriteExisting = True

    'Configures Variables
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set WshEnv = WshShell.Environment("Process")
    Set WshNetwork = CreateObject("WScript.Network")

    Set objSysInfo = CreateObject("ADSystemInfo")
    Set objDomain = getObject("LDAP://rootDse")
    DomainString = objDomain.Get("dnsHostName")

    'Grab the user name
    UserString = WshNetwork.UserName
    Set objCurrentUser = GetObject("LDAP://" & objSysInfo.UserName)
    Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
    strUser = objSysInfo.UserName
    Set objUser = GetObject("LDAP://" & strUser)

    'renvoi du full username au format "Nom, Prénom" (utiliser pour la configuration Outlook
    GetFullUserName = objUser.FullName
   
   
End Function

'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Test existance profil Outlook
'Renvoi 0 si le profil est déjà existant, 1 si il n'y a pas de profil et 2 si Outlook n'est pas installé. En cas d'existance du profil, ProfileName en contient le nom.
Function OutlookProfilIsSet(byRef ProfileName)
on error resume next
' Declare the variables
    Dim wshShell, ObjFs
    ' Create an Object File System object
    Set objFS = CreateObject ("Scripting.FileSystemObject")
        ' Create a wshShell object
    Set wshShell = createObject("wscript.shell")
   
    'test si Outlook est installé.
    If objFS.FileExists(WshShell.ExpandEnvironmentStrings("%systemroot%")+"\fonts\outlook.ttf") Then
    'Lecture du nome du profil existant dans la base de registre
      ProfileName = wshShell.RegRead(strRegOutlookProfilePath)
      If Err.number <> 0 Then
          Err.Clear
            OutlookProfilIsSet = OutlookNoProfil   
            ProfileName = ""
      Else
          OutlookProfilIsSet = OutlookProfilExist       
      End If
    Else
        OutlookProfilIsSet = OutlookNotInstalled
        ProfileName = ""
    End IF
    'Libération de la mémoire
    Set wshShell = nothing
    Set objFS = nothing

End Function

'**************************************************************************************************
' CONFIGURATION OUTLOOK
'/!\ Requiert RichProfile.exe dans le même dossier
'**************************************************************************************************
Function SetOutlook

    ' Declare the variables
    dim wshNet, wshShell, FullUserName, ProfileOutlook, ProfileName
        ' Create a wshShell object
    set wshShell = createObject("wscript.shell")

    FullUserName = GetFullUserName
    SetOutlook = "  Configuration du profil Outlook pour """ & FullUserName &""" réussie"

      If OutlookProfilIsSet(ProfileName) = OutlookNoProfil Then
          'Lancement de RichProfile.exe
        ProfileOutlook = "richProfile " & strServeurExchange & " " & FullUserName & " Outlook  N  D"
        wshShell.run ProfileOutlook,,true           
      ElseIf OutlookProfilIsSet(ProfileName) = OutlookProfilExist then
          SetOutlook = "  Un profil outlook existe déjà!"           
        ElseIf OutlookProfilIsSet(ProfileName) = OutlookNotInstalled then
            SetOutlook = "  Outlook n'est pas installé"
        End IF
   
    'Libération de la mémoire
    Set wshNet = nothing
    Set wshShell = nothing

       
End Function

En éspérant avoir pu t'aider
0
phil_iiep Messages postés 1 Date d'inscription samedi 23 juillet 2005 Statut Membre Dernière intervention 13 décembre 2008
13 déc. 2008 à 13:56
c'est me
j'ai essayé votre script, cela ne semble pas fonctionner ne connaissant rien a VBS pourriez vous m'indiquer comment debugue mon probleme?
je travaille avec Exchange 2003 et outlook2003
ca fonctionne avec uniquement mais il n'ya pas de controle sur le profile!!

'**************************************
'User Profile Config Script
'www.itedge.net
'Version 3.0 - September 2005
'**************************************

Dim WshShell
Dim domcont
Dim exchsvr
Dim mbox
Dim exepath
Dim outlkset

'**************************************
'Environment Variables to Configure
'**************************************
exchsvr = "london" 'Exchange Server
domcont = "london" 'Domain Controller with proprofile.exe in the netlogon share


Set WshShell = WScript.CreateObject("WScript.Shell")

'******************************
' Outlook Profile Setup
'******************************
mbox = WSHShell.ExpandEnvironmentStrings ("%USERNAME%")
exepath = "\" & domcont & "\netlogon\richprofile.exe"
outlkset = exepath & " " & exchsvr & " " & mbox & " " & mbox & " N D"

WSHShell.run outlkset

PauseTime = 655535
Start = Timer
Do While Timer < Start + PauseTime
Loop
0
Rejoignez-nous