none
Criar perfil Outlook

    Question

  •  

    Pessoal,

    Preciso de um script que crie um perfil para o usuário logado no outlook 2007.

    Ele tem que pegar os dados do usuário logado e criar o perfil e defini-lo como default, sem interação nenhuma com o usuario, quando ele abrir o outlook seus emails já estarão todos lá.

    Tenho o script que segue abaixo, porém é necessário clicar em avançar a cada vez que é solicitado.

    Se possível agradeço.

    Muito obrigado

     

    Segue script:

     

    '***************************************************
    ' File:    auto_outlook.vbs
    ' Author:  Mark M Manning
    ' Date:    10/10/2007
    ' Version: 1
    ' Based on the work of Peder Pedersen - pep@deif.com
    '***************************************************

    Option Explicit

    Dim Company, PRFLocation, ProfileName

     

    ' =========================================
    ' ====== EDIT THIS INFORMATION=============
    Company = "Furukawa"          ' SET THE NAME OF YOUR COMPANY
    PRFLocation = "c:\test.prf"         ' SET THE LOCATION ON THE NETWORK OR LOCAL DRIVE
    'PRFLocation = "\\SERVER\share\test.prf" ' OF THE PRF THAT HAS BEEN CREATE
    ProfileName = "Site_Profile"   ' This is the name that you have already
          ' created when you made the PRF. 
          ' make sure they are the same
    ' =========================================

     

     


    ' =================DO NOT EDIT ANYTHING BELOW THIS SECTION================
    ' ========================================================================

    Set WshShell = CreateObject("WScript.Shell")
    Set WshNetwork = Wscript.CreateObject("Wscript.Network")
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ObjEnv = WshShell.Environment("Process")
    Set objShell = CreateObject("Shell.Application")
    Set objSysInfo = CreateObject("ADSystemInfo")
    Set objUser = GetObject("LDAP://" & objSysInfo.UserName)

    Const HKEY_CURRENT_USER = &H80000001
    Dim HKCUfirstRunflag
    HKCUfirstRunflag = "HKCU\Software\" & Company & "\FirstRunFlag"
    Dim HKCUprofile
    HKCUprofile = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & ProfileName

    Dim WshShell, WshNetwork, objEnv, fso, objShell, username, key, FirstRunCurrentUser, MSOKey, NoProfile, OfficeInstalled, strUserName, strInitials
    Dim strOfficePath, strMachineName, objSysInfo, objUser
    Dim objWord, LogonSrv, PRFPath, result, OSnummer, objWMIService, colOperatingSystems, objOperatingSystem

    strOfficePath = "Software\Microsoft\Office\11.0\Common\UserInfo" 'Path for office user info
    strMachineName = "."

    ' ============== START OF MAIN SCRIPT ==============
     'Check OS
    ' =========================================
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strMachineName & "\root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery _
        ("Select * from Win32_OperatingSystem")
    For Each objOperatingSystem in colOperatingSystems
     result =  objOperatingSystem.Version
    OSnummer = Left(result,3)

    if OSnummer <> "5.1" then
     'Wscript.Echo "This is not XP"  'Debug
     Wscript.Quit  
    else
     'Wscript.Echo OSnummer     'Debug
    end if
    Next
    ' =========================================
    'Test to see if the script has run before
    ' =========================================
    'TestfirstRunUser  ' Has script been run before?
    'If FirstRunCurrentUser then 'If not then continue
    ' TestProfile
    ' If NoProfile then 'Set up profile if none exists
      OutlookSetup 'Setup Outlook profile
    ' End if
    'end if
    ' =========================================

    ' Add a registry key if the script runs successfully
    'WshShell.RegWrite HKCUfirstrunflag, "1", "REG_DWORD"

    'cleanup

    ' ================================================
    ' ============== END OF MAIN SCRIPT ==============
    ' ================================================

    ' -------- Test if first run for this user?
    'Sub TestFirstRunUser
    '  on error resume next 'cannot be read first time
    '  key = WshShell.RegRead(HKCUfirstRunflag)
    '  If Err <> 0 Then
    '    FirstRunCurrentUser = True
    '  Else
    '    FirstRunCurrentUser = False
    '  End If
    '  On Error Goto 0
    'End Sub


    '------------ Test if profile exists?
    'Sub TestProfile
    ' on error resume next 'cannot be read first time
    ' MSOKey = WshShell.RegRead(HKCUprofile)
    ' determine if a profile has already been setup
    '  If MSOKey = "" Then
    '   'wscript.echo "No Profile" 'Testing
    '   NoProfile = True
    '  else
    '   'wscript.echo "Profile exists" 'Testing
    '   NoProfile = False
    '  end if
    '  On Error Goto 0
    'End sub

    Sub OutlookSetup
        WshShell.Run "outlook.exe /importprf " & PRFLocation, 1, False
    End Sub

    Sub Cleanup
     Set WshNetwork = Nothing
     Set objSysInfo = Nothing
     Set WshShell = Nothing
     Set fso = Nothing
     Set ObjEnv = Nothing
     Set objShell = Nothing
     Set objUser = Nothing
     Set objWord = Nothing
     Set objWMIService = Nothing
     Set colOperatingSystems = Nothing
     Set objWord = Nothing
    End Sub

    Thursday, April 08, 2010 6:58 PM

Answers

All replies